473,803 Members | 2,038 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how do I link a datagridview to a dataset?

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

mydataadapter.f ill(myds, "test")
datagridview1.? ???????

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

mydataadapter.f ill(myds, "test")
datagrid1.DataG rid1.SetDataBin ding(ds, tableName)

but in 2008 with the datagridview setdatabinding doesn't exist.
Jun 27 '08 #1
5 2860
On Thu, 19 Jun 2008 14:59:45 -0400, cj <cj@nospam.nosp amwrote:
>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.Data Grid1.SetDataBi nding(ds, tableName)

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

datagridview1.d ataSource = dataset1.Tables ("stevedog")

and you can set a currencyManager object like this

dim curMg As CurrencyManager

curMgr = Ctype(Me.Bindin gContext(datase t1.Tables("stev edog"),
CurrencyManger)

CurMgr.Position = 0
txtPos.Text = (CurMgr.Positio n + 1).ToString
txtCount.Text = CurMgr.Count.To String

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.d ataSource = dataset1.Tables ("stevedog")

and you can set a currencyManager object like this

dim curMg As CurrencyManager

curMgr = Ctype(Me.Bindin gContext(datase t1.Tables("stev edog"),
CurrencyManger)

CurMgr.Position = 0
txtPos.Text = (CurMgr.Positio n + 1).ToString
txtCount.Text = CurMgr.Count.To String

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.d ataSource = dataset1.Tables ("stevedog")

and you can set a currencyManager object like this

dim curMg As CurrencyManager

curMgr = Ctype(Me.Bindin gContext(datase t1.Tables("stev edog"),
CurrencyManger)

CurMgr.Position = 0
txtPos.Text = (CurMgr.Positio n + 1).ToString
txtCount.Text = CurMgr.Count.To String

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.D ataSource = bs
////

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

mydataadapter.f ill(myds, "test")
datagridview1.? ???????

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

mydataadapter.f ill(myds, "test")
datagrid1.DataG rid1.SetDataBin ding(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
8368
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: DataGridView.Rows(5) <=====> DataSet.Rows(5) .
10
39517
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 some DataGridViewTextBoxCell, DataGridViewComboBoxCell etc, i want to export all that to XML.. Any help is greatly appreciated.
2
24562
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 you update after closing the grid/form, etc.? Also, can you tell me the best book to buy that fully explains the DataGridView control? Thanks.
3
11949
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 the DataSet as it binds. Can I specify a column on the DataSet that, sorted, will control the order of the rows in the datagridview? It seems to just parse over the data in the DataSet and bind to it, without my being able to control the order...
2
8738
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 checkbox columns that are not bounded the table. This datagridview is located in the tab (2nd). I thought I mention that since that might be part of the problem (?). When the applications start, it will need some parameter criteria selection...
4
18710
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 put DataGridView and BindingSource, and connected them (BindingSource of course is also connected with DataSet). Next on the separated thread I'm reading data from DB and load them do DataSet (more preciselly, readed data I've saved as XML and...
7
15665
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 there an equivalent property for the DataGridView? I have searched, but have not found one. I would like the user to be able to see all the columns of the table on one screen - thus eliminating the need to use the horizontal scroll bar to view...
0
1173
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 displays the appropriate DataTable. When a user changes some of the settings in my program, I sometimes have to recreate some of the DataTables, however, the DataGridView will still somehow display the original DataTable even if the DataGridView...
1
8139
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 populate it: DataSet ds = new DataSet(); dgvShipmentHistory.DataSource = null;
0
9562
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10542
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10068
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9119
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6840
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5625
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4274
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3795
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2968
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.