Solved

How to remove dafault nulls from the datagrid on the form?

Posted on 2006-06-27
3
173 Views
Last Modified: 2010-04-23
My code is:

 Dim ds As New DataSet
        dt = ds.Tables.Add("CourseInfo")
        dt.Columns.Add("Course", GetType(String))
        dt.Columns.Add("Course Date (MMDDYY)", GetType(String))


        grdCourse.DataSource = dt
        Dim ts As New DataGridTableStyle
        ts.MappingName = "CourseInfo"
        grdCourse.TableStyles.Clear()
        grdCourse.TableStyles.Add(ts)

        ts.GridColumnStyles(0).Width = 150
        ts.GridColumnStyles(1).Width = 170

When entering the valus on the form, I see the word null in the datagrid.
How can I get rid of that?

Please help.

Thanks.
0
Comment
Question by:Reeds
  • 3
3 Comments
 
LVL 35

Expert Comment

by:YZlat
ID: 16994919
Dim i As Integer
        For i = 0 To dt.Columns.Count
            dt.Columns(i).DefaultValue = ""
        Next
0
 
LVL 35

Expert Comment

by:YZlat
ID: 16994922
sorry, use

Dim i As Integer
        For i = 0 To dt.Columns.Count - 1
            dt.Columns(i).DefaultValue = ""
        Next
0
 
LVL 35

Accepted Solution

by:
YZlat earned 500 total points
ID: 16994931
Dim ds As New DataSet
Dim i as integer
        dt = ds.Tables.Add("CourseInfo")
        dt.Columns.Add("Course", GetType(String))
        dt.Columns.Add("Course Date (MMDDYY)", GetType(String))

 For i = 0 To dt.Columns.Count - 1
            dt.Columns(i).DefaultValue = ""
        Next

        grdCourse.DataSource = dt
        Dim ts As New DataGridTableStyle
        ts.MappingName = "CourseInfo"
        grdCourse.TableStyles.Clear()
        grdCourse.TableStyles.Add(ts)

        ts.GridColumnStyles(0).Width = 150
        ts.GridColumnStyles(1).Width = 170

0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question