Call and add item into Comboboxes that are new in datagridview

madani

New member
Joined
Aug 3, 2019
Messages
1
Programming Experience
Beginner
In my program I have some combobox with variable number(depends on user choice) in first two rows of a datagrid view. Now I want to add item and work with them in other classes but I don't have access to them because I don't know how to call them before creating?(they are been created during runtime)
//this is how I create them:

for (int j = 0; j < columncount; j++)
{
dataGridView1.Rows.Cells[j] = new DataGridViewComboBoxCell();
}
 
Other objects should not be directly accessing those cells anyway. A control should only be accessed directly by the form it's on. Any other object would interact with the form. The specific nature of that interaction would depend on the relationship of the object to the form. The most likely relationship is that the form creates the object. In that case, the form would pass data into the object by setting properties and/or calling methods and passing arguments, while it would get data out by getting properties and/or calling methods and getting return values. If the object specifically needed to pass data to the form then it would raise an event that the form could handle.
 
Back
Top Bottom