HighTechTalks DotNet Forums  

DataTable - set a specific row.

VB.net microsoft.public.dotnet.languages.vb


Discuss DataTable - set a specific row. in the VB.net forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Mr. X.
 
Posts: n/a

Default DataTable - set a specific row. - 05-22-2010 , 10:26 AM






Hello.
How can I set a specific row of a dataTable ?
(I.e the DataTable has 10 rows, and I want to focus on row no. 7).

Thanks

Reply With Quote
  #2  
Old   
Onur Güzel
 
Posts: n/a

Default Re: DataTable - set a specific row. - 05-22-2010 , 11:43 AM






On May 22, 6:26*pm, "Mr. X." <nospam (AT) nospam_please (DOT) com> wrote:
Quote:
Hello.
How can I set a specific row of a dataTable ?
(I.e the DataTable has 10 rows, and I want to focus on row no. 7).

Thanks
Assuming your DataTable is bounded to a DataGridView because of using
term "focus" which you may have meant it as "selecting"?

So, you can do:

' Drag and drop a datagridview and make sure it has one column at
least.
'-----------------------------------
Dim dt As New DataTable
' Adding 9 rows upon existing one, which will be 10 in total.
For x As Integer = 1 To 9

Dim drow As DataRow = dt.NewRow

dt.Rows.Add(drow)
Next


DataGridView1.DataSource = dt

DataGridView1.Rows(0).Selected = False
DataGridView1.Rows(6).Selected = True
'-----------------------------------

HTH,

Onur Güzel

Reply With Quote
  #3  
Old   
Mr. X.
 
Posts: n/a

Default Re: DataTable - set a specific row. - 05-22-2010 , 11:54 AM



I forgive for now using bindingSource - it seems too complicated, because
there are many things I need to do manually.
There is no connection to bindingSource.
But, as it seems, DataTable is only a container.
To go to the current row, I need bindingSource
So I think I try using bindingSource as a solution, but not connect it
directly to dataGridView object.

Thanks

"Onur Güzel" <kimiraikkonen85 (AT) gmail (DOT) com> wrote

Quote:
On May 22, 6:26 pm, "Mr. X." <nospam (AT) nospam_please (DOT) com> wrote:
Hello.
How can I set a specific row of a dataTable ?
(I.e the DataTable has 10 rows, and I want to focus on row no. 7).

Thanks

Assuming your DataTable is bounded to a DataGridView because of using
term "focus" which you may have meant it as "selecting"?

So, you can do:

' Drag and drop a datagridview and make sure it has one column at
least.
'-----------------------------------
Dim dt As New DataTable
' Adding 9 rows upon existing one, which will be 10 in total.
For x As Integer = 1 To 9

Dim drow As DataRow = dt.NewRow

dt.Rows.Add(drow)
Next


DataGridView1.DataSource = dt

DataGridView1.Rows(0).Selected = False
DataGridView1.Rows(6).Selected = True
'-----------------------------------

HTH,

Onur Güzel

Reply With Quote
  #4  
Old   
Mr. X.
 
Posts: n/a

Default Re: DataTable - set a specific row. - 05-22-2010 , 12:04 PM



O.K.
My assumption works.
I am using BindingSource, but not connect it directly to dataGridView
object.
Now thing works fine ...

Anyway, Thanks

Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.