vb.net - Datagridview converting Datetime to String -
how convert datagridview item (datetime format) string.
this code:
combobox1.text = datagridview1.item(4, 1).value.tostring()
can help me? total code:
private sub datagridview1_cellclick(sender object, e datagridviewcelleventargs) handles datagridview1.cellclick btnedit.visible = true dim integer = datagridview1.currentrow.index dim x string = cstr(datagridview1.item(4, i).value.tostring) dim y string = cstr(datagridview1.item(5, i).value.tostring) msgbox(x) msgbox(y) txttrainid.text = datagridview1.item(0, i).value txtrouteid.text = datagridview1.item(1, i).value txtline.text = datagridview1.item(2, i).value cmbline1.text = datagridview1.item(3, i).value cmbline2.text = datagridview1.item(3, i).value cmbline3.text = datagridview1.item(3, i).value cmbts.text = x.tostring cmbta.text = y.tostring txttrainname.text = datagridview1.item(6, i).value cmbflag.text = datagridview1.item(7, i).value end sub
if want display value
combobox
property must set dropdownstyle = dropdown
, don't need i = datagridview1.currentrow.index
currentrowindex
of datagridview
in cellclick event
private sub datagridview1_cellclick(sender object, e datagridviewcelleventargs) handles datagridview1.cellclick combobox1.text = datagridview1.item(4, e.rowindex).value.tostring() end sub
vb.net datagridview typeconverter
No comments:
Post a Comment