Solved

Create a Disconnected Dataset bound to a Datagrid

Posted on 2004-10-12
4
309 Views
Last Modified: 2010-04-23
I am forced to gather information from methods of a COM object, and display it in a datagrid. Of course the big problem is - NO Database! Boy is it hard to find help on this one. I thought I would ask you gurus.

How to I manually create and populate a dataset table & bind it to a noneditable datagrid (if that matters)? I am amazed at how difficult this seems. I have found other solutions to populate the datagrid, but they all have little quirks. I was told that datagrids should really be bound to datsets. Any ideas?
0
Comment
Question by:JeepGeekin
  • 2
  • 2
4 Comments
 
LVL 10

Expert Comment

by:Hans Langer
ID: 12287578
Hi, Try this:

 Dim ds As New DataSet

   Private Sub FilldsManually_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

      Dim dt As New DataTable
      Dim dr As DataRow

      'Create dataTable
      dt.Columns.Add("MyFirstColumn")
      dt.Columns.Add("MySecondColumn")

      'Create DataRow
      dr = dt.NewRow
      dr("MyFirstColumn") = "Hello"
      dr("MySecondColumn") = "Bye"
      dt.Rows.Add(dr)

      ds.Tables.Add(dt)

      DataGrid1.DataSource = ds

   End Sub

   Private Sub AddRow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
      Dim dr As DataRow


      'Create DataRow
      dr = ds.Tables(0).NewRow
      dr("MyFirstColumn") = "Hello"
      dr("MySecondColumn") = "Bye"
      ds.Tables(0).Rows.Add(dr)

   End Sub
0
 

Author Comment

by:JeepGeekin
ID: 12288172
Oh sure. Make it seem that simple!
Looks like it works, but I am getting something new in my datagrid I have not seen before.

It shows up with just a plus sign. When I click on it, it shows me "Table1". When I click on Table 1, the data fills out the datagrid. Any idea why it is doing this?
0
 
LVL 10

Accepted Solution

by:
Hans Langer earned 500 total points
ID: 12288248
sorry, I forget this line:

DataGrid1.DataSource = ds
DataGrid1.DataMember = ds.Tables(0).TableName.ToString
0
 

Author Comment

by:JeepGeekin
ID: 12288265
Excellent!
I actually came back out to tell you I figured it out (with my tail between my legs). Thanks for your help. This is exactly what I needed!
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

707 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now