Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DataGridView Default Value

Status
Not open for further replies.

klornpallier

Technical User
Aug 28, 2002
98
GB
I guess this is really easy if you now how but how do you add a default value to a DataGridView cell. I tried the following off msdn but it dont work:

Private Sub VARIABLE_INPUTDataGridView1_DefaultValuesNeeded(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewRowEventArgs) Handles VARIABLE_INPUTDataGridView1.DefaultValuesNeeded


With e.Row
.Cells("LOCK_USER").Value = "0"
End With

End Sub
 
Set this in your DataTable
Code:
YourDataTable.Columns("YourColumn").DefaultValue = "0"
 
Thank you I tried as you described in the forms load event but the default value does not appear in the datagrid:

KPPERSON.VARIABLE_INPUT.Columns("PERIOD").DefaultValue = "2"

I get the error below:

Object reference not set to an instance of an object.

Any Idea
 
My guess is that you don't really have a column named "PERIOD." Maybe you need to try "Period"?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top