c# - Winform DataGridView not refreshing after changing datasource programmatically -


i have datagridview won't update contents after programmatically setting it's datasource. i've verified new data fine, , tried .refresh, setting datasource nothing , few other things redraw new data. i've spent hours trying every combination of events (even downgrading dotnet framework 3.5 see if bug in 4.5 framework) , tricks other forums. nothing works.

public sub getneworders(optional calledfrompopup boolean = false)     me.dgvorders.datasource = qbi.order_dataict.getnewordersict()     if calledfrompopup         ''100% datasource info has changed, yet datagridview won't reflect change!         me.pnlorders.refresh() 'does not work         me.dgvorders.refresh() 'does not work     end if end sub 

basically, form opened, calls "getneworders" in form.closing event, closes. calling form has method above , checks see if needs refresh datagridview (a solution thought work, but, alas, not). can see, i've tried refreshing panel datagridview in (as form itself). refresh absolutely nothing , there no redraw or rebind or can find force datagridview reload itself. stumped! answers in either c# or vb.net language okay.


another version of function showing other things i've tried

public sub getneworders(optional calledfrompopup boolean = false)     me.dgvorders.datasource = nothing 'does not work     me.dgvorders.datamember = "" 'does not work     me.dgvorders.datasource = qbi.order_dataict.getnewordersict() '100% datasource info has changed, yet datagridview won't reflect change!      if calledfrompopup         me.pnlorders.refresh() 'does not work         me.dgvorders.refresh() 'does not work         me.dgvorders.show() 'does not work         me.dgvorders.visible = false 'does not work         me.dgvorders.visible = true 'does not work     end if end sub 

success!! figured out have use showdialog() instead of show() when opening child form, when closes, need check dialogresult.cancel, call function getneworders parent in:

   dim frm2 new frmsendtoquickbookspopup     frm2.currentorder = order     frm2.lineitems = ordlineitems     frm2.payments = ordpayments     dim diaresult dialogresult = frm2.showdialog()      if diaresult = windows.forms.dialogresult.cancel         getneworders()     end if 

to explain: frm2 opened , when closed, datagridview (which on parent form) sees closed , calls method getneworders().


Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -