.net - How to check if datagridview cell is Null -


i want display message if value of cell of datagridview null. please advise how it. , best regards,

furqan

you need check if value property of datagridviewcell nothing (the equivalent of null in c#).

you can following code:

if mydatagridview.currentcell.value nothing     messagebox.show("cell empty") else     messagebox.show("cell contains value") end if 


if want inform user when try leave cell has been left empty, need use similar code in cellvalidating event handler method. example:

private sub mydatagridview_cellvalidating(byval sender object,                byval e datagridviewcellvalidatingeventargs)                handles mydatagridview.cellvalidating     if mydatagridview.item(e.columnindex, e.rowindex).value nothing         ' show user message         messagebox.show("you have left cell empty")          ' fail validation (prevent them leaving cell)         e.cancel = true     end if end sub 

Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -