Basically their are so many ways to solve this problem. but in this iam used simple way. I think it may be
helpful for beginners.
Drag and drop two Comboxes in windows form:
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace droupdown { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { } private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { if (comboBox1.SelectedItem == "B.Tech") { comboBox2.Items.Add("IT"); comboBox2.Items.Add("CSE"); } else if (comboBox1.SelectedItem == "PG") { comboBox2.Items.Clear(); comboBox2.Items.Add("MCA"); comboBox2.Items.Add("MBA"); } else { MessageBox.Show("select item"); } } } }
In this i took very less Items so it will work but what about for large number of items…? I will give solution for that one in ASP.Net. Thank You.
No comments:
Post a Comment