How to display a selected item from a combobox into a gridvi
what i want to do is basically is once an item is selected in the combobox ,it should directly be added into the datagridview once i click on a button called add in a simple windows form application. please help
Isham KhanPosted May 3, 2015, 4:23 AM
dt.Columns.Add("Name");
dataGridView1.DataSource = dt;
under Add Button Write this Code
dt.Rows.Add(comboBox1.SelectedItem.ToString());
If this helps u plz Mark as Answer
Susovan BiswasPosted May 14, 2015, 6:14 AM
First globally declare your datatable:-
public static DataTable dt = new DataTable();
put the following code inside the form load event:
Put the following code inside the button click event.
dr = dt.NewRow();
dt.Rows.Add(dr);
dt.AcceptChanges();
dataGridView1.DataSource = dt;
Isham KhanPosted May 3, 2015, 8:39 AM
shosho shoshoPosted May 3, 2015, 8:27 AM
Isham KhanPosted May 3, 2015, 8:25 AM
shosho shoshoPosted May 3, 2015, 8:22 AM
Isham KhanPosted May 3, 2015, 8:20 AM
shosho shoshoPosted May 3, 2015, 8:17 AM
Isham KhanPosted May 3, 2015, 8:14 AM
shosho shoshoPosted May 3, 2015, 8:12 AM
Isham KhanPosted May 3, 2015, 8:10 AM
shosho shoshoPosted May 3, 2015, 8:07 AM
WinCore.Domain.Course
WinCore.Domain.GPA
Isham KhanPosted May 3, 2015, 7:49 AM
shosho shoshoPosted May 3, 2015, 7:43 AM
Isham KhanPosted May 3, 2015, 7:14 AM
make DAtatable global ,, declare outside of block
shosho shoshoPosted May 3, 2015, 6:42 AM
This is how i am doing it..
Isham KhanPosted May 3, 2015, 5:12 AM
Isham KhanPosted May 3, 2015, 5:10 AM
shosho shoshoPosted May 3, 2015, 5:06 AM
shosho shoshoPosted May 3, 2015, 4:44 AM
DataTable dt = new DataTable();
dt.Columns.Add("Name");
dataGridView1.DataSource = dt;