?
Solved

Create a Disconnected Dataset bound to a Datagrid

Posted on 2004-10-12
4
Medium Priority
?
316 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
[X]
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
  • 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 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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 …
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

752 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