您好我有一个数据网格控件(不是datagridview控件)放在一个Windows窗体(Vb)它有10列。我试图在其中一个列中输入十进制值,但它正在重置其值。例如:
我在一个单元格中有31个并且在我更改单元格时尝试将其编辑为20.5,它会重置为31.如果我输入任何整数值,如21,则接受该值。
_da = New OleDbDataAdapter("SELECT EMPDETAILPERSONAL.EMPCODE, EMPDETAILPERSONAL.EMPNAME, EMPDETAILPERSONAL.EMPDEPT, EMPDETAILPERSONAL.EMPDOB, 0 AS AGE, " & _
" EMPDETAILPERSONAL.EMPDOJ, EMPDETAILPERSONAL.EMPPANNP, " & Date.DaysInMonth(selYear, selMonth) & " AS NOD, " & Date.DaysInMonth(selYear, selMonth) & " AS LD, CSDEPT.CSDEPTNAME, EMPDETAILPERSONAL.EMPDESG, " & _
" EMPDETAILPERSONAL.EMPSALACC, EMPDETAILPERSONAL.EMPPFACC, EMPDETAILPERSONAL.EMPPPFACC, EMPDETAILPAYROLL.EMPBASIC, EMPDETAILPAYROLL.EMPGPA, CDbl(0) AS CONS, " & _
" EMPDETAILPAYROLL.EMPDA, EMPDETAILPAYROLL.EMPHRA, EMPDETAILPAYROLL.EMPTA, EMPDETAILPAYROLL.EMPMISCADD, EMPDETAILPAYROLL.EMPGRSAL, " & _
" EMPDETAILPAYROLL.EMPPFMEM, EMPDETAILPAYROLL.EMPITAX, EMPDETAILPAYROLL.EMPMISCDED, EMPDETAILPAYROLL.EMPNETSAL, " & _
" IIf(EMPLOAN.LOANAMTINST Is Null,0,EMPLOAN.LOANAMTINST) AS LOAN, CSDESIGNATION.CSDESGNAME, EMPDETAILPAYROLL.EMPINCDATE, EMPDETAILPAYROLL.EMPINCAPP, " & _
" EMPDETAILPAYROLL.EMPBASIC AS o_basic, EMPDETAILPAYROLL.EMPGPA AS o_gpa, EMPDETAILPAYROLL.EMPDA AS o_da, " & _
" EMPDETAILPAYROLL.EMPHRA AS o_hra, EMPDETAILPAYROLL.EMPTA AS o_ta, EMPDETAILPAYROLL.EMPPFMEM AS o_pf, EMPDETAILPAYROLL.EMPPFEMPL AS o_pf_e, " & _
" EMPDETAILPAYROLL.EMPPPFEMPL AS o_ppf_e, EMPDETAILPAYROLL.EMPPFEMPL, EMPDETAILPAYROLL.EMPPPFEMPL, " & _
" EMPDETAILPAYROLL.EMPMISCADD AS o_add, EMPDETAILPAYROLL.EMPITAX AS o_tax, EMPDETAILPAYROLL.EMPMISCDED AS o_less, " & _
" IIf(EMPLOAN.LOANAMTINST Is Null,0,EMPLOAN.LOANAMTINST) AS o_loan, CDbl(0) AS EMPCONTRI,EMPDETAILPAYROLL.EMPCCA AS CCA,EMPDETAILPAYROLL.EMPMEDALL AS MEDALL,EMPDETAILPAYROLL.EMPOTHERALL AS OTHERALL,EMPDETAILPAYROLL.EMPESI AS ESI,EMPDETAILPAYROLL.EMPGPF AS GPF,EMPDETAILPAYROLL.EMPPAYSCALE AS PAYSCALE " & _
" FROM EMPLOAN RIGHT JOIN (((EMPDETAILPERSONAL INNER JOIN CSDEPT ON EMPDETAILPERSONAL.EMPDEPT = CSDEPT.CSDEPTID) " & _
" INNER JOIN EMPDETAILPAYROLL ON (EMPDETAILPERSONAL.EMPDESG = EMPDETAILPAYROLL.EMPDESG) AND (EMPDETAILPERSONAL.EMPDEPT = EMPDETAILPAYROLL.EMPDEPT) " & _
" AND (EMPDETAILPERSONAL.EMPCODE = EMPDETAILPAYROLL.EMPCODE)) INNER JOIN CSDESIGNATION ON EMPDETAILPERSONAL.EMPDESG = CSDESIGNATION.CSDESGID) " & _
" ON EMPLOAN.EMPCODE = EMPDETAILPERSONAL.EMPCODE " & _
" WHERE EMPDETAILPERSONAL.EMPDOL Is Null ORDER BY IIF(EMPDETAILPERSONAL.EMPDESG = 1, '10','20') + EMPDETAILPERSONAL.EMPCODE", _con)
_da.Fill(_dtEmp)
dgEmp.DataSource = _dtEmp
在cellchanged事件中没有任何内容。甚至在触发cellchanged事件之前重置值。请帮忙。感谢
答案 0 :(得分:1)
您应该确保datatable
的相应列不是整数类型。如果给定列是某种integer
,则此条件会反映在datagrid
列中,当您输入带小数的值时,它们会被转换回integer
。