C# Refresh DataGridView with another Form -


i have problem not being able refresh form has datagridview. open form called maintenanceform. here choose car, give amount of km, , option add products. if click on add products button, form stay open while open called addproducts. in form choose list of products add final listbox. if click save, these items go bindinglist , populate grid. have tested closing first form first , reopening second form. grid populated. how populate grid without having close first form? here methods i'm using

save button on second form:

private void btnopslaan_click(object sender, eventargs e) {     lsttotal = new bindinglist<product>();     foreach (object product in listbtotal.items)     {         lsttotal.add((product)product);      }     maintenanceform maintenanceform = new maintenanceform();     maintenanceform.filldatagridview(lsttotal);     this.close(); } 

method populate grid:

public void filldatagridview(bindinglist<product> products) {     dgvproducts.datasource = null;     dgvproducts.autogeneratecolumns = false;     dgvproducts.allowusertoaddrows = false;     dgvproducts.datasource = products;     dgvproducts.refresh();  } 

again maintenanceform still open while addproductsform open?

thanks in advance

thanks user jdb have fixed problem.

instead of making new instance (thank junaith correcting me it) i'm making logicalparent method.

public adminform logicalparent { get; set; }

with have access al methods , functions of parent form , no problems refreshing.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -