473,387 Members | 1,321 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

how do I link a datagridview to a dataset?

cj
In VB 2008 how do I link the datagridview to a dataset?

mydataadapter.fill(myds, "test")
datagridview1.????????

When I was using 2005 I used the datagrid and it was done like:

mydataadapter.fill(myds, "test")
datagrid1.DataGrid1.SetDataBinding(ds, tableName)

but in 2008 with the datagridview setdatabinding doesn't exist.
Jun 27 '08 #1
5 2837
On Thu, 19 Jun 2008 14:59:45 -0400, cj <cj@nospam.nospamwrote:
>In VB 2008 how do I link the datagridview to a dataset?

mydataadapter.fill(myds, "test")
datagridview1.????????

When I was using 2005 I used the datagrid and it was done like:

mydataadapter.fill(myds, "test")
datagrid1.DataGrid1.SetDataBinding(ds, tableName)

but in 2008 with the datagridview setdatabinding doesn't exist.
DataGridView1.DataSource = myds
Jun 27 '08 #2
I had problems using databinding so I just did this:

datagridview1.dataSource = dataset1.Tables("stevedog")

and you can set a currencyManager object like this

dim curMg As CurrencyManager

curMgr = Ctype(Me.BindingContext(dataset1.Tables("stevedog" ),
CurrencyManger)

CurMgr.Position = 0
txtPos.Text = (CurMgr.Position + 1).ToString
txtCount.Text = CurMgr.Count.ToString

You can increment CurMgr like this

CurMgr.Position += 1

in the Click event of the datagridview or in the RowEnter event.

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Jun 27 '08 #3
I had problems using databinding so I just did this:

datagridview1.dataSource = dataset1.Tables("stevedog")

and you can set a currencyManager object like this

dim curMg As CurrencyManager

curMgr = Ctype(Me.BindingContext(dataset1.Tables("stevedog" ),
CurrencyManger)

CurMgr.Position = 0
txtPos.Text = (CurMgr.Position + 1).ToString
txtCount.Text = CurMgr.Count.ToString

You can increment CurMgr like this

CurMgr.Position += 1

in the Click event of the datagridview or in the RowEnter event.

Rich

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Jun 27 '08 #4
cj
Thanks, I took your advise.

Rich P wrote:
I had problems using databinding so I just did this:

datagridview1.dataSource = dataset1.Tables("stevedog")

and you can set a currencyManager object like this

dim curMg As CurrencyManager

curMgr = Ctype(Me.BindingContext(dataset1.Tables("stevedog" ),
CurrencyManger)

CurMgr.Position = 0
txtPos.Text = (CurMgr.Position + 1).ToString
txtCount.Text = CurMgr.Count.ToString

You can increment CurMgr like this

CurMgr.Position += 1

in the Click event of the datagridview or in the RowEnter event.

Rich

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Jun 27 '08 #5
cj.

The datasource in the DataGridView exist from version 2005, it exist in the
DataGrid, the ListBox and the Combobox from version 2002.

However, in version 2008 it is better to place the bindingsource between it
as some problems are then fixed while behaviour in old programs stay the
same.

\\\
Dim bs As New BindingSource
bs.DataSource = dt
DataGridView1.DataSource = bs
////

Cor
"cj" <cj@nospam.nospamschreef in bericht
news:e6**************@TK2MSFTNGP06.phx.gbl...
In VB 2008 how do I link the datagridview to a dataset?

mydataadapter.fill(myds, "test")
datagridview1.????????

When I was using 2005 I used the datagrid and it was done like:

mydataadapter.fill(myds, "test")
datagrid1.DataGrid1.SetDataBinding(ds, tableName)

but in 2008 with the datagridview setdatabinding doesn't exist.
Jun 27 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Robert Koller | last post by:
Hello i have this problem: In a DataGridView the user work with data from a DataSet. on Start the row index from datagridview is the same as the row index from the dataset. Also: ...
10
by: Henok Girma | last post by:
Hello Gurus, I want to save the state of an unbound DataGridView on my Windows Form application to an XML file so i can later load it back.. Basically, on my form I have a DataGridView, it's got...
2
by: bob | last post by:
Can anyone tell me the best way to update a dataset while it is being edited/viewed in the DataGridView control? Is this something that should be inserted into one of the grid's events? or should...
3
by: joey.powell | last post by:
I have a datagridview where I set its "DataSource" property to a DataSet and its "DataMember" property to a table within the DataSet. I need for the DataGridView to "sort" through the contents of...
2
by: Rick Shaw | last post by:
Hi, I have a problem with the datagridview not refreshed when the application first appear on the screen. The datagridview display data from a table in the dataset. At the same time, I've added...
4
by: shibeta | last post by:
Hello, I have problem with DataGridView and BindingSource. I have created DataSet and added TableData to it with manualy created columns (without DataAdapter - I'm not using MSSQL). On the Form I...
7
by: =?Utf-8?B?TG9zdEluTUQ=?= | last post by:
Hi All :) I'm converting VB6 using True DBGrid Pro 8.0 to VB2005 using DataGridView. True DBGrid has a MultipleLines property that controls whether individual records span multiple lines. Is...
0
by: Chris | last post by:
I have a DataGridView in a form that will display the information from various DataTables in my DataSet. The user is provided a list of tables and when they select a table name, the DataGridView...
1
by: =?Utf-8?B?UmFodnlu?= | last post by:
Hi All; I'm working in VS2005, and have a DataGridView that is bound to a datasource. Is there a way to change a column to be a link style column after the DataGridView populates? Here's how I...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.