korasoglu Posted February 2, 2017 Share Posted February 2, 2017 Arkadaşlar normal olarak ekleme yapabiliyorum ToolStripItem item = new ToolStripMenuItem(); item.Text = "Jhon Smith"; item.Name = "Ekle"; item.Click += new EventHandler(item_Click); ama toolStripDropDownButton ekleyip Click yapmak istiyorum yapamadım yardımcı olursanız sevinirim Quote Link to comment Share on other sites More sharing options...
xmen14 Posted February 2, 2017 Share Posted February 2, 2017 kodla oluşturduğun ToolStripMenuItem nesnesini click evet ekleyip çalıştırmak mı amacın. Quote Link to comment Share on other sites More sharing options...
korasoglu Posted February 2, 2017 Author Share Posted February 2, 2017 Hem ekleyip hemde çalıştırmak aynen Quote Link to comment Share on other sites More sharing options...
korasoglu Posted February 2, 2017 Author Share Posted February 2, 2017 (edited) DataTable data2 = SQL.GetDataTable("select ad FROM isimler"); foreach (DataRow item in data2.Rows) { this.toolStripDropDownButton2.DropDownItems.Add(item["ad"].ToString()); this.toolStripDropDownButton2.DisplayStyle = ToolStripItemDisplayStyle.Text; } bu şekilde ekledim ama ne çalıştırabildim ne itemleri silebildim toolStripDropDownButton1.DropDownItems.Clear(); ama Edited February 2, 2017 by korasoglu Quote Link to comment Share on other sites More sharing options...
KintaRo Posted February 2, 2017 Share Posted February 2, 2017 toolStripDropDownButton1.DropDownItems.Clear(); DataTable data = new DataTable(); data.Columns.Add("isim"); data.Columns.Add("sehir"); data.Rows.Add("ali", "bursa"); data.Rows.Add("veli", "adana"); data.Rows.Add("ahmet", "hatay"); foreach (DataRow item in data.Rows) { string isim = item["isim"].ToString(); ToolStripMenuItem menuItem = new ToolStripMenuItem() { Text = isim, }; toolStripDropDownButton1.DropDownItems.Add(menuItem); } Quote Link to comment Share on other sites More sharing options...
xmen14 Posted February 2, 2017 Share Posted February 2, 2017 6 saat önce, korasoglu yazdı: Arkadaşlar normal olarak ekleme yapabiliyorum ToolStripItem item = new ToolStripMenuItem(); item.Text = "Jhon Smith"; item.Name = "Ekle"; item.Click += new EventHandler(item_Click); ama toolStripDropDownButton ekleyip Click yapmak istiyorum yapamadım yardımcı olursanız sevinirim private void Form2_Load(object sender, EventArgs e) { ToolStrip menu = new ToolStrip(); ToolStripItem item = new ToolStripMenuItem(); item.Width = 100; item.Name = "ToolStripMenuItem1"; item.Text = "ToolStripMenuItem1"; this.Controls.Add(menu); menu.Items.Add(item); item.Click += new EventHandler(item_Click); } void item_Click(object sender, EventArgs e) { Form1 frm = new Form1(); frm.Show(); this.Hide(); } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.