I have very little access to winform and recently Want To Do This function:
Add a column (out of the data source) to the datagridview)
Solution:
1. manually add a column to the datagridview (right-click the datagridview)
2. The datagridview is bound to the datatable data source. In this case, my data in ComboBox is
3. loop through each row of the datagridview and bind data to ComboBox (dropdownlist.
PS: It's just a personal method. I think this method is not very efficient. After all, it is bound with two data records. Please give me some tips if you have any good methods.
For (INT I = 0; I <datagridview1.rows. Count-1; I ++)
{
VaR dropdownlist = (datagridviewcomboboxcell) datagridview1.rows [I]. cells ["column2"]; // obtain the control ComboBox
admintableadapter ata = new admintableadapter (); // instantiate the adapter
datatable dt = ATA. getdata (); // obtain the data source
dropdownlist. datasource = DT; // bind the data source
dropdownlist. displaymember = "username";
dropdownlist. valuemember = "ID";
}