Click here to Skip to main content
15,888,047 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How do i not have the zeros show when i load my form

VB
Public Class Form1
 Private Sub Form1_Load1(sender As Object, e As System.EventArgs) Handles Me.Load

myTable.Columns.Add("Shake /Cereal", GetType(Integer))
       myTable.Columns.Add("Entrees", GetType(Integer))
       myTable.Columns.Add("Bar", GetType(Integer))
       myTable.Columns.Add("Total", GetType(Integer))

       myTable.Columns("Shake /Cereal").DefaultValue = 0
       myTable.Columns("Entrees").DefaultValue = 0
       myTable.Columns("Bars").DefaultValue = 0

End Sub

Private Sub DataGridView1_CellEndEdit(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellEndEdit

        myTable.Columns("Total").Expression = "[Shake /Cereal] + Entrees + Bars"
End Sub
Posted
Updated 30-Aug-13 1:48am
v2

1 solution

You want to show empty textbox for default values when user wants to enter data?
Don't supply default values to the datatable, as that will get picked up while databinding.

If you must set your datasource's defaults, then you need to override the OnEdit event to put blanks in the textboxes. Crude way, but it works.

However, it will be better if you show 0, since it will give a better idea to the users that the input expected is an integer and they will not try to enter a string.
 
Share this answer
 
Comments
PythonProgrammer 30-Aug-13 8:37am    
if i take the default 0's away they wont add up across as i type in a number..however i want to get rid of the zeros

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900