简体   繁体   English

第一页的组合框值显示在第二页的文本框中

[英]Combobox value from first page show in textbox of second page

在此处输入图片说明

I just pass info from this page and save in data base now when I click on submit I want in new page course name is available from page 1 so I can update rest of detail in database thanks in advance 我仅从此页面传递信息,然后单击“提交”,现在就将其保存在数据库中。新页面中的课程名称可从第1页获得,因此我可以更新数据库中的其他详细信息,谢谢

Add this code in the submit Button_click 在提交Button_click添加此代码

Form2.TextBox1.Text = cboMyCombo.SelectedValue();
Form2.Show();

you can access to your ComboBox Item by comboBox.SelectedItem and then to pass it's value to another form in another class, this couls be helpful: 您可以通过comboBox.SelectedItem访问您的ComboBox Item,然后将其值传递给另一个类中的另一种形式,这对您有帮助:
How to display Multiple values from form1 to form3 如何显示从Form1到Form3的多个值

On the form where you have the ComboBox on the click of Submit Button you can do something like this 在具有“提交”按钮单击的“组合框”的表单上,您可以执行以下操作

Letz say your Page1 is ExtCourse than 让我们说您的Page1比

ExtCourse.CourseName = ComboBoxCourse.GetItemText(this.ComboBoxCourse.SelectedItem);

and on ExtCourse.cs 以及在ExtCourse.cs上

public string CourseName { get; set; }

than you can assign 比你可以分配的

TextBoxCourseName.Text = CourseName;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM