PC Review


Reply
Thread Tools Rate Thread

Adding rows to DataGrid

 
 
David Sawyer
Guest
Posts: n/a
 
      8th Sep 2003
When I try and use DataGrid I cannot find any command to
add rows or pre-set a number of rows. I would like to
build a table of 34 rows and 5 colums.

 
Reply With Quote
 
 
 
 
One Handed Man [ OHM ]
Guest
Posts: n/a
 
      8th Sep 2003
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim row As DataRow
Dim colIdx, rowIdx As Integer

'Bind
dg.DataSource = tab
For colIdx = 1 To 5
tab.Columns.Add(CType(colIdx, String))
Next
For rowIdx = 1 To 35
row = tab.NewRow()
row("1") = CType(rowIdx, String)
tab.Rows.Add(row)
Next




End Sub


 
Reply With Quote
 
One Handed Man [ OHM ]
Guest
Posts: n/a
 
      8th Sep 2003
Put the tab declaration as a form class member

Public Class Form1
Inherits System.Windows.Forms.Form
Dim tab As New DataTable("MyTable") ' <<<<<<<<<<<<<<<<<<<



"One Handed Man [ OHM ]" <terry_burnsREMOVE%FOR%NO%(E-Mail Removed)>
wrote in message news:%(E-Mail Removed)...
> Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles Button1.Click
>
> Dim row As DataRow
> Dim colIdx, rowIdx As Integer
>
> 'Bind
> dg.DataSource = tab
> For colIdx = 1 To 5
> tab.Columns.Add(CType(colIdx, String))
> Next
> For rowIdx = 1 To 35
> row = tab.NewRow()
> row("1") = CType(rowIdx, String)
> tab.Rows.Add(row)
> Next
>
>
>
>
> End Sub
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
adding new rows to datagrid =?Utf-8?B?QXNoYQ==?= Microsoft ASP .NET 1 22nd Jun 2005 06:20 PM
How to prevent drawing DataGrid rows while adding rows? =?Utf-8?B?VFQgKFRvbSBUZW1wZWxhZXJlKQ==?= Microsoft C# .NET 2 6th Apr 2005 04:51 PM
Adding rows to a datagrid =?Utf-8?B?RGVlcGE=?= Microsoft Dot NET 0 28th Mar 2005 10:03 PM
DataGrid - Adding Rows Jim Heavey Microsoft ASP .NET 3 14th Nov 2003 11:34 PM
Re: Adding rows to a Datagrid Paul J Microsoft ASP .NET 0 21st Jul 2003 05:20 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:18 AM.