Solved

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

Posted on 2006-06-27
3
172 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…

809 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