Hi...
I have 2 Forms. I add Leauges to comboBox, and add the teams to the leauge which is selected in cmbBox in Form1 also add the properties of team...Form2 has a listview. My problem is when i push a button in Form1, Listview must show the properties which i added in Form1.
i changed the Modifier prop. of combobox1 and also added it to Form2.
it works if i do this in the same Form.
in form 1 :
Form_UrunListesi f = null; private void btn_Listele1_Click(object sender, EventArgs e){
if (f==null){
f =
new Form_UrunListesi();f.ShowDialog();
}
}
in form2
//this code adds the properties of teams to the listview.
foreach (ürünlerim ürr in ((ÜrünTipi)comboBox1.SelectedItem).Ürünlerim){
ListViewItem lvi = new ListViewItem(new string[]{ürr.ÜrünlerimMarkaAdi,ürr.ÜrünModeli,ürr.UrunlerimOzellikleri,
ürr.ÜrünAlisFiyati,ürr.ÜrünSatisFiyati,
Convert.ToString(ürr.StokMiktari)});listView1.Items.Add(lvi);
thanks...
yusufPosted Dec 19, 2007, 11:50 AM
Hi Alan. i have solved the problem after i posted this question. i am grateful for your quickness, thanks again Alan ..
AlanPosted Dec 19, 2007, 11:39 AM
Hi yusuf,
Basically, what you need to do to access comboBox1 on form1 from code on form2 is the following (.NET 2.0 or later assumed):
1. Make comboBox1 a public rather than a private field on form1
2. Get a reference to form1 using this code on form2 (as I'm not sure of the class name of form1, I've just called it Form1);
Form1 f1 = (Form1)Application.OpenForms["Form1"];
3. comboBox1 can now be accessed from form2 using the expression:
f1.comboBox1