Posted on 2006-06-16
Last Modified: 2010-04-23
Using a datagrid to show dataset. I'd like to add a column to my table. I've looked into the code already present, and the only way i've found so far was to play into the Windows Form Designer generated code

Any better idea ? some quick editing tips to add a column. Coze adding it this way can be long.
Question by:TheSonics
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
  • 2
  • +1
LVL 17

Expert Comment

ID: 16920642
Dim dsDataset As New DataSet

dsDataset.Tables(0).Columns("NewColumn").DataType = GetType(Integer)
dsDataset.Tables(0).Columns("NewColumn").ColumnName = "MyNewColumn"


Expert Comment

ID: 16920646
just reconfigure data adapter

Author Comment

ID: 16920965
Pretty nice, i want that row to be a checkbox. Increased point :P
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 16920969
i meant column, to be checkbox.
LVL 17

Expert Comment

ID: 16921953
For a checkbox, you simply need to change the Datatype of the column.  A checkbox can have values of True/False, which is a Boolean, so:

 dsDataset.Tables(0).Columns("NewColumn").DataType = GetType(Boolean)

Author Comment

ID: 16922985
Here how is it working:

I have a column named "Resp" using :
    Friend WithEvents dsHistoricRespCol As System.Data.DataColumn
    Friend WithEvents dgtbHistoricRespColStyle As System.Windows.Forms.DataGridTextBoxColumn

When I do resizing or similaire stuff, i do the modifications on the datagridtextboxcolumn.

So far i have added the column via the .NET interface and it creates a datacolumn. But how do I set a style via the interface ?

        Me.dgtbMeasLimitMaxColStyle.Format = ""
        Me.dgtbMeasLimitMaxColStyle.FormatInfo = Nothing
        Me.dgtbMeasLimitMaxColStyle.HeaderText = resources.GetString("dgtbMeasLimitMaxColStyle.HeaderText")
        Me.dgtbMeasLimitMaxColStyle.MappingName = resources.GetString("dgtbMeasLimitMaxColStyle.MappingName")
        Me.dgtbMeasLimitMaxColStyle.NullText = resources.GetString("dgtbMeasLimitMaxColStyle.NullText")
        Me.dgtbMeasLimitMaxColStyle.Width = CType(resources.GetObject("dgtbMeasLimitMaxColStyle.Width"), Integer)

Knowing the defenition of the style column, it is using the resources files, so it gotta be created via some "tools". I dont think its efficient to edit all this stuff manually.

Author Comment

ID: 16934466
any suggestions ?
LVL 96

Expert Comment

by:Bob Learned
ID: 16935124
Are you looking to display a column using check boxes, using the a column style?

LVL 96

Accepted Solution

Bob Learned earned 500 total points
ID: 16935563
Through the interface, you can define a DataGridBoolColumn by pulling down the drop-down list: 


Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

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 ( Literal, only instead of starting and ending with w…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

623 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