Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How do I dynamically set up a DataGridTableStyle and DataGridTextBoxColumns when the number of columns from my datatable or dataview may change each time?

Posted on 2006-03-31
3
Medium Priority
?
228 Views
Last Modified: 2010-04-23
I want to eliminate Null from the cells. My research indicates I need to use DataGridTableStyle to accomplish this. But my columns may come and go depending on what data is available in my datatable or dataview. How do I dynamically do that when I seem to need a new DataGridTextBoxColumn for each column?
0
Comment
Question by:IT_Steve
3 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 16346985
You can eliminate nulls at the source, depending on what type of datasource you are binding to.

Bob
0
 
LVL 14

Accepted Solution

by:
amyhxu earned 2000 total points
ID: 16347328
Hi IT_Steve,

Here's the easy way to do it without specifically setting up each DataFridTextBoxColumn:

     After you set the datasource of the datagrid, add the following code:

        Dim myGridTableStyle As DataGridTableStyle = New DataGridTableStyle
        myGridTableStyle.MappingName = DataGrid1.DataSource.TableName
        DataGrid1.TableStyles.Clear()
        DataGrid1.TableStyles.Add(myGridTableStyle)

        For Each dgtbc As DataGridTextBoxColumn In DataGrid1.TableStyles(0).GridColumnStyles
            dgtbc.NullText = ""
        Next
0
 

Author Comment

by:IT_Steve
ID: 16351697
Amyhxu -

Thank you ...that was exactly what I needed. I like this easy solution.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
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…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

810 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