0

How to populate a combobox which already contain data from selected value in datagridview.

I have two forms in which formA contain datagridview and formB contains textboxes, comboboxes, and datagridview. When clicking add button in formA the formB will show and receive values which user enters and store in database. But the problem is that when clicking edit after selecting a row from formA how do i display the values in combobox and erase the old values from combobox

4th Nov 2017, 2:22 AM
Nihal
2 Answers
0
You need to use " combobox.Items.Clear(); " to clear the all the values of the textbox. For transferring the selected rows from formA to formB you need to pass it through parameters.
4th Nov 2017, 1:21 PM
Shawaine
Shawaine - avatar
0
for transferring data here is an example. in formA editButton formB b = new fromB(datagridview[rowIndex,columnIndex].Value.ToString()); in formB find the constructor of make a new one with one parameter like this public formB(string text){ InitialzeComponents(); //then assign the text to the combobox combobox.Items.Add(text); }
4th Nov 2017, 1:32 PM
Shawaine
Shawaine - avatar