vb.net - data from datagridview not displayed into textbox (Visual Studio 2010) -
i've been dealing hours!!! have 2 forms: in 1 form (form1) have layout textboxes, etc... in other (datagrid_form2) have datagridview choose item, doubleclickcell event, loaded in specific textbox of first form (form1).
i have button next textbox of form1 call datagrid_form2, once element in datagrid_form2 chosen textbox of form1 loaded value.
public sub data_celldoubleclick(byval sender object, byval e system.windows.forms.datagridviewcelleventargs) handles data.celldoubleclick dim form1panel new form1 form1panel.txtmybox.text = mydata.selectedcells.item(0).value.tostring debug.writeline(form1panel.txtmybox.text ) me.close() end sub
as can see have celldoubleclick event should load value of selected cell textbox of form1, doesn't display in textbox(txtmybox). in debug value chosen correctly, not problem of code, value not being passed @ textbox.
any ideas? hints?
thanks in advance
p.s. i'm working visual studio 2010 .vb project!
it seems messing forms.
creating new instance of form1 don't show it.
suggest read this.
question similar this
edit: not clear questions how want achieve ask. have form datagridview (i name frmdgv) , second form (form1) want show cell content yours datagrid. form (form1) opened? or want open new 1 each time double click? , if want open each time want multiple instances or 1 in modal ?
i'll try include everything:
->the form open each time
frmdgv
public sub data_celldoubleclick(byval sender object, byval e system.windows.forms.datagridviewcelleventargs) handles data.celldoubleclick dim f1 new form1 f1=directcast(mlinkform1,form1) f1.txtmybox.text = mydata.selectedcells.item(0).value.tostring 'if want open form1 each time double click in cell f1.show 'if want modal style info 'f1.showdialog 'f1.dispose end sub
->the form open (i wouldn't follow this)
frmdgv
private mlinkform1 form1 public property linkform1 return mlinkform1 end set(value) mlinkform1 = value end set end property
'when open form first time set:
dim f1 new form1 mlinkform1=f1 f1.show public sub data_celldoubleclick(byval sender object, byval e system.windows.forms.datagridviewcelleventargs) handles data.celldoubleclick dim f1 new form1 f1=directcast(mlinkform1,form1) f1.txtmybox.text = mydata.selectedcells.item(0).value.tostring end sub
edit 3 (i don't have visual studio right , code not tested)
form: datagridview
private mlinkform1 form1 public property linkform1 return mlinkform1 end set(value) mlinkform1 = value end set end property public sub data_celldoubleclick(byval sender object, byval e system.windows.forms.datagridviewcelleventargs) handles data.celldoubleclick linkform1.txtmybox.text = mydata.selectedcells.item(0).value.tostring me.close() end sub
form: form1
private sub button1_click(sender system.object, e system.eventargs) handles button1.click datagridview.linkform1=me datagridview.show end sub
try , inform me.
Comments
Post a Comment