我有一個帶有組合框的Windows窗體應用程序。我將項目添加到組合框(例如,1,2,3,4)。如果我在組合框中選擇一個項目,SelectedIndex應該返回到另一個類中的變量。將值設置爲來自另一個類的變量
class Form1
{
private void Combobox1_SelecetedIndexChanged(object sender,eventArgs e)
{
combobox1.selecetdeIndex ; //I will get the selected index.
//If the selected index is changed then the currentValue in the AnotherClass should be
//changed.
}
}
Class AnotherClass
{
private int currentValue;
//There are some methods which depends on currentValue.
}
某些代碼請[從另一種形式的C#呼叫可變]的 – 2011-06-07 09:23:02
可能重複(http://stackoverflow.com/questions/5928071/call-variable-from-another-form-c) – 2011-06-07 09:35:47
Form1類 { 私人無效Combobox1_SelecetedIndexChanged(對象發件人,EventArgs的) { //我將得到所選索引 } } – Karthik 2011-06-07 10:01:03