473,545 Members | 937 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Data Grid Row Count

I have datagrid filled with some data rows. At the run time i want know how
many total rows are there in the data grid ?

Any idea ? Any Suggestions ?

Thanks in advance

Tej
Nov 20 '05 #1
6 6679
With Deft Fingers, "Tejpal Garhwal" <te************ @ocs.com> wrote:
I have datagrid filled with some data rows. At the run time i want know how
many total rows are there in the data grid ?


I think this format will work (doesn't matter which Table you use)

Label1.Text = DataSet.TableNa me.Rows.Count

Bruce
Nov 20 '05 #2
Thanks Bruce, but your code with return the row count of Datatable not the
DataGrid. I need the row count for DataGrid.

I know you have the answer for this too :)

"Tejpal Garhwal" <te************ @ocs.com> wrote in message
news:uL******** ******@TK2MSFTN GP09.phx.gbl...
I have datagrid filled with some data rows. At the run time i want know how many total rows are there in the data grid ?

Any idea ? Any Suggestions ?

Thanks in advance

Tej

Nov 20 '05 #3
Everything you can bind the grid to, a collection, datatable, dataview, and
even dataset, will have something that's enumerable and can be counted...it
depends what you are binding to.

DataTable.Rows. Count should work as Mr. B mentioned unless you are binding
to something else. What is the grid bound to? If a DataView, then
Dataview.rows.c ount. If a strongly typed collection then
Collection.Item s.Count.

HTH,

Bill
"Tejpal Garhwal" <te************ @ocs.com> wrote in message
news:OY******** ******@TK2MSFTN GP10.phx.gbl...
Thanks Bruce, but your code with return the row count of Datatable not the
DataGrid. I need the row count for DataGrid.

I know you have the answer for this too :)

"Tejpal Garhwal" <te************ @ocs.com> wrote in message
news:uL******** ******@TK2MSFTN GP09.phx.gbl...
I have datagrid filled with some data rows. At the run time i want know

how
many total rows are there in the data grid ?

Any idea ? Any Suggestions ?

Thanks in advance

Tej


Nov 20 '05 #4
My Datagrid is bound to Datatable which i am creating and populating the
datagrid with this datatable at the run time.

"William Ryan" <do********@com cast.nospam.net > wrote in message
news:Om******** ******@TK2MSFTN GP11.phx.gbl...
Everything you can bind the grid to, a collection, datatable, dataview, and even dataset, will have something that's enumerable and can be counted...it depends what you are binding to.

DataTable.Rows. Count should work as Mr. B mentioned unless you are binding
to something else. What is the grid bound to? If a DataView, then
Dataview.rows.c ount. If a strongly typed collection then
Collection.Item s.Count.

HTH,

Bill
"Tejpal Garhwal" <te************ @ocs.com> wrote in message
news:OY******** ******@TK2MSFTN GP10.phx.gbl...
Thanks Bruce, but your code with return the row count of Datatable not the DataGrid. I need the row count for DataGrid.

I know you have the answer for this too :)

"Tejpal Garhwal" <te************ @ocs.com> wrote in message
news:uL******** ******@TK2MSFTN GP09.phx.gbl...
I have datagrid filled with some data rows. At the run time i want
know how
many total rows are there in the data grid ?

Any idea ? Any Suggestions ?

Thanks in advance

Tej



Nov 20 '05 #5
Please post this code you are using to fill a datagrid from a datatable.

"Tejpal Garhwal" <te************ @ocs.com> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
My Datagrid is bound to Datatable which i am creating and populating the
datagrid with this datatable at the run time.

"William Ryan" <do********@com cast.nospam.net > wrote in message
news:Om******** ******@TK2MSFTN GP11.phx.gbl...
Everything you can bind the grid to, a collection, datatable, dataview,

and
even dataset, will have something that's enumerable and can be

counted...it
depends what you are binding to.

DataTable.Rows. Count should work as Mr. B mentioned unless you are binding
to something else. What is the grid bound to? If a DataView, then
Dataview.rows.c ount. If a strongly typed collection then
Collection.Item s.Count.

HTH,

Bill
"Tejpal Garhwal" <te************ @ocs.com> wrote in message
news:OY******** ******@TK2MSFTN GP10.phx.gbl...
Thanks Bruce, but your code with return the row count of Datatable not

the DataGrid. I need the row count for DataGrid.

I know you have the answer for this too :)

"Tejpal Garhwal" <te************ @ocs.com> wrote in message
news:uL******** ******@TK2MSFTN GP09.phx.gbl...
> I have datagrid filled with some data rows. At the run time i want know how
> many total rows are there in the data grid ?
>
> Any idea ? Any Suggestions ?
>
> Thanks in advance
>
> Tej
>
>



Nov 20 '05 #6
Let me brief you what exact i want to do with this code :

I am reading registry data (presently its hard coaded) and populating it in
the datatable which is bound to datagrid. user can update the registry data
in the grid and on click of save it should update the registry... which is
not happending.. datatable seems empty..

Thanks for your help
Imports System

Imports System.Data

Imports Microsoft.Win32

Imports System.Data.Sql Client

Public Class Configuration

Inherits System.Windows. Forms.Form

Private dataTable As System.Data.Dat aTable

Private maxColumnNumber As Integer

Private maxRowNumber As Integer

#Region " Windows Form Designer generated code "

Public Sub New()

MyBase.New()

'This call is required by the Windows Form Designer.

InitializeCompo nent()

'Add any initialization after the InitializeCompo nent() call

End Sub

'Form overrides dispose to clean up the component list.

Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)

If disposing Then

If Not (components Is Nothing) Then

components.Disp ose()

End If

End If

MyBase.Dispose( disposing)

End Sub

'Required by the Windows Form Designer

Private components As System.Componen tModel.IContain er

'NOTE: The following procedure is required by the Windows Form Designer

'It can be modified using the Windows Form Designer.

'Do not modify it using the code editor.

Friend WithEvents btnReadRegistry As System.Windows. Forms.Button

Friend WithEvents tvRegistry As System.Windows. Forms.TreeView

Friend WithEvents dtgRegistry As System.Windows. Forms.DataGrid

Friend WithEvents imglstConfigura tion As System.Windows. Forms.ImageList

Friend WithEvents btnCancel As System.Windows. Forms.Button

Friend WithEvents btnSave As System.Windows. Forms.Button

Friend WithEvents DataSetConfigur ation As System.Data.Dat aSet

Friend WithEvents SqlConnectionCo nfiguration As
System.Data.Sql Client.SqlConne ction

<System.Diagnos tics.DebuggerSt epThrough()> Private Sub InitializeCompo nent()

Me.components = New System.Componen tModel.Containe r()

Dim resources As System.Resource s.ResourceManag er = New
System.Resource s.ResourceManag er(GetType(Conf iguration))

Me.btnReadRegis try = New System.Windows. Forms.Button()

Me.tvRegistry = New System.Windows. Forms.TreeView( )

Me.imglstConfig uration = New System.Windows. Forms.ImageList (Me.components)

Me.dtgRegistry = New System.Windows. Forms.DataGrid( )

Me.btnCancel = New System.Windows. Forms.Button()

Me.btnSave = New System.Windows. Forms.Button()

Me.DataSetConfi guration = New System.Data.Dat aSet()

Me.SqlConnectio nConfiguration = New System.Data.Sql Client.SqlConne ction()

CType(Me.dtgReg istry, System.Componen tModel.ISupport Initialize).Beg inInit()

CType(Me.DataSe tConfiguration,
System.Componen tModel.ISupport Initialize).Beg inInit()

Me.SuspendLayou t()

'

'btnReadRegistr y

'

Me.btnReadRegis try.AccessibleD escription =
CType(resources .GetObject("btn ReadRegistry.Ac cessibleDescrip tion"), String)

Me.btnReadRegis try.AccessibleN ame =
CType(resources .GetObject("btn ReadRegistry.Ac cessibleName"), String)

Me.btnReadRegis try.Anchor =
CType(resources .GetObject("btn ReadRegistry.An chor"),
System.Windows. Forms.AnchorSty les)

Me.btnReadRegis try.BackgroundI mage =
CType(resources .GetObject("btn ReadRegistry.Ba ckgroundImage") ,
System.Drawing. Image)

Me.btnReadRegis try.Dock = CType(resources .GetObject("btn ReadRegistry.Do ck"),
System.Windows. Forms.DockStyle )

Me.btnReadRegis try.Enabled =
CType(resources .GetObject("btn ReadRegistry.En abled"), Boolean)

Me.btnReadRegis try.FlatStyle =
CType(resources .GetObject("btn ReadRegistry.Fl atStyle"),
System.Windows. Forms.FlatStyle )

Me.btnReadRegis try.Font = CType(resources .GetObject("btn ReadRegistry.Fo nt"),
System.Drawing. Font)

Me.btnReadRegis try.Image =
CType(resources .GetObject("btn ReadRegistry.Im age"), System.Drawing. Image)

Me.btnReadRegis try.ImageAlign =
CType(resources .GetObject("btn ReadRegistry.Im ageAlign"),
System.Drawing. ContentAlignmen t)

Me.btnReadRegis try.ImageIndex =
CType(resources .GetObject("btn ReadRegistry.Im ageIndex"), Integer)

Me.btnReadRegis try.ImeMode =
CType(resources .GetObject("btn ReadRegistry.Im eMode"),
System.Windows. Forms.ImeMode)

Me.btnReadRegis try.Location =
CType(resources .GetObject("btn ReadRegistry.Lo cation"), System.Drawing. Point)

Me.btnReadRegis try.Name = "btnReadRegistr y"

Me.btnReadRegis try.RightToLeft =
CType(resources .GetObject("btn ReadRegistry.Ri ghtToLeft"),
System.Windows. Forms.RightToLe ft)

Me.btnReadRegis try.Size = CType(resources .GetObject("btn ReadRegistry.Si ze"),
System.Drawing. Size)

Me.btnReadRegis try.TabIndex =
CType(resources .GetObject("btn ReadRegistry.Ta bIndex"), Integer)

Me.btnReadRegis try.Text = resources.GetSt ring("btnReadRe gistry.Text")

Me.btnReadRegis try.TextAlign =
CType(resources .GetObject("btn ReadRegistry.Te xtAlign"),
System.Drawing. ContentAlignmen t)

Me.btnReadRegis try.Visible =
CType(resources .GetObject("btn ReadRegistry.Vi sible"), Boolean)

'

'tvRegistry

'

Me.tvRegistry.A ccessibleDescri ption =
CType(resources .GetObject("tvR egistry.Accessi bleDescription" ), String)

Me.tvRegistry.A ccessibleName =
CType(resources .GetObject("tvR egistry.Accessi bleName"), String)

Me.tvRegistry.A nchor = CType(resources .GetObject("tvR egistry.Anchor" ),
System.Windows. Forms.AnchorSty les)

Me.tvRegistry.B ackColor = System.Drawing. SystemColors.Wi ndow

Me.tvRegistry.B ackgroundImage =
CType(resources .GetObject("tvR egistry.Backgro undImage"),
System.Drawing. Image)

Me.tvRegistry.D ock = CType(resources .GetObject("tvR egistry.Dock"),
System.Windows. Forms.DockStyle )

Me.tvRegistry.E nabled = CType(resources .GetObject("tvR egistry.Enabled "),
Boolean)

Me.tvRegistry.F ont = CType(resources .GetObject("tvR egistry.Font"),
System.Drawing. Font)

Me.tvRegistry.I mageIndex =
CType(resources .GetObject("tvR egistry.ImageIn dex"), Integer)

Me.tvRegistry.I mageList = Me.imglstConfig uration

Me.tvRegistry.I meMode = CType(resources .GetObject("tvR egistry.ImeMode "),
System.Windows. Forms.ImeMode)

Me.tvRegistry.I ndent = CType(resources .GetObject("tvR egistry.Indent" ),
Integer)

Me.tvRegistry.I temHeight =
CType(resources .GetObject("tvR egistry.ItemHei ght"), Integer)

Me.tvRegistry.L ocation = CType(resources .GetObject("tvR egistry.Locatio n"),
System.Drawing. Point)

Me.tvRegistry.N ame = "tvRegistry "

Me.tvRegistry.N odes.AddRange(N ew System.Windows. Forms.TreeNode( )
{CType(resource s.GetObject("tv Registry.Nodes. Nodes"),
System.Windows. Forms.TreeNode) })

Me.tvRegistry.R ightToLeft =
CType(resources .GetObject("tvR egistry.RightTo Left"),
System.Windows. Forms.RightToLe ft)

Me.tvRegistry.S electedImageInd ex =
CType(resources .GetObject("tvR egistry.Selecte dImageIndex"), Integer)

Me.tvRegistry.S ize = CType(resources .GetObject("tvR egistry.Size"),
System.Drawing. Size)

Me.tvRegistry.T abIndex = CType(resources .GetObject("tvR egistry.TabInde x"),
Integer)

Me.tvRegistry.T ext = resources.GetSt ring("tvRegistr y.Text")

Me.tvRegistry.V isible = CType(resources .GetObject("tvR egistry.Visible "),
Boolean)

'

'imglstConfigur ation

'

Me.imglstConfig uration.ColorDe pth =
System.Windows. Forms.ColorDept h.Depth8Bit

Me.imglstConfig uration.ImageSi ze =
CType(resources .GetObject("img lstConfiguratio n.ImageSize"),
System.Drawing. Size)

Me.imglstConfig uration.ImageSt ream =
CType(resources .GetObject("img lstConfiguratio n.ImageStream") ,
System.Windows. Forms.ImageList Streamer)

Me.imglstConfig uration.Transpa rentColor = System.Drawing. Color.Transpare nt

'

'dtgRegistry

'

Me.dtgRegistry. AccessibleDescr iption =
CType(resources .GetObject("dtg Registry.Access ibleDescription "), String)

Me.dtgRegistry. AccessibleName =
CType(resources .GetObject("dtg Registry.Access ibleName"), String)

Me.dtgRegistry. Anchor = CType(resources .GetObject("dtg Registry.Anchor "),
System.Windows. Forms.AnchorSty les)

Me.dtgRegistry. BackColor = System.Drawing. SystemColors.In fo

Me.dtgRegistry. BackgroundImage =
CType(resources .GetObject("dtg Registry.Backgr oundImage"),
System.Drawing. Image)

Me.dtgRegistry. CaptionFont = CType(resources .GetObject("dtg Registry.Captio nF
ont"), System.Drawing. Font)

Me.dtgRegistry. CaptionText = resources.GetSt ring("dtgRegist ry.CaptionText" )

Me.dtgRegistry. DataMember = ""

Me.dtgRegistry. Dock = CType(resources .GetObject("dtg Registry.Dock") ,
System.Windows. Forms.DockStyle )

Me.dtgRegistry. Enabled = CType(resources .GetObject("dtg Registry.Enable d"),
Boolean)

Me.dtgRegistry. Font = CType(resources .GetObject("dtg Registry.Font") ,
System.Drawing. Font)

Me.dtgRegistry. HeaderForeColor = System.Drawing. SystemColors.Co ntrolText

Me.dtgRegistry. ImeMode = CType(resources .GetObject("dtg Registry.ImeMod e"),
System.Windows. Forms.ImeMode)

Me.dtgRegistry. Location = CType(resources .GetObject("dtg Registry.Locati on"),
System.Drawing. Point)

Me.dtgRegistry. Name = "dtgRegistr y"

Me.dtgRegistry. RightToLeft =
CType(resources .GetObject("dtg Registry.RightT oLeft"),
System.Windows. Forms.RightToLe ft)

Me.dtgRegistry. Size = CType(resources .GetObject("dtg Registry.Size") ,
System.Drawing. Size)

Me.dtgRegistry. TabIndex = CType(resources .GetObject("dtg Registry.TabInd ex"),
Integer)

Me.dtgRegistry. Visible = CType(resources .GetObject("dtg Registry.Visibl e"),
Boolean)

'

'btnCancel

'

Me.btnCancel.Ac cessibleDescrip tion =
CType(resources .GetObject("btn Cancel.Accessib leDescription") , String)

Me.btnCancel.Ac cessibleName =
CType(resources .GetObject("btn Cancel.Accessib leName"), String)

Me.btnCancel.An chor = CType(resources .GetObject("btn Cancel.Anchor") ,
System.Windows. Forms.AnchorSty les)

Me.btnCancel.Ba ckgroundImage =
CType(resources .GetObject("btn Cancel.Backgrou ndImage"),
System.Drawing. Image)

Me.btnCancel.Do ck = CType(resources .GetObject("btn Cancel.Dock"),
System.Windows. Forms.DockStyle )

Me.btnCancel.En abled = CType(resources .GetObject("btn Cancel.Enabled" ),
Boolean)

Me.btnCancel.Fl atStyle = CType(resources .GetObject("btn Cancel.FlatStyl e"),
System.Windows. Forms.FlatStyle )

Me.btnCancel.Fo nt = CType(resources .GetObject("btn Cancel.Font"),
System.Drawing. Font)

Me.btnCancel.Im age = CType(resources .GetObject("btn Cancel.Image"),
System.Drawing. Image)

Me.btnCancel.Im ageAlign = CType(resources .GetObject("btn Cancel.ImageAli gn"),
System.Drawing. ContentAlignmen t)

Me.btnCancel.Im ageIndex = CType(resources .GetObject("btn Cancel.ImageInd ex"),
Integer)

Me.btnCancel.Im eMode = CType(resources .GetObject("btn Cancel.ImeMode" ),
System.Windows. Forms.ImeMode)

Me.btnCancel.Lo cation = CType(resources .GetObject("btn Cancel.Location "),
System.Drawing. Point)

Me.btnCancel.Na me = "btnCancel"

Me.btnCancel.Ri ghtToLeft =
CType(resources .GetObject("btn Cancel.RightToL eft"),
System.Windows. Forms.RightToLe ft)

Me.btnCancel.Si ze = CType(resources .GetObject("btn Cancel.Size"),
System.Drawing. Size)

Me.btnCancel.Ta bIndex = CType(resources .GetObject("btn Cancel.TabIndex "),
Integer)

Me.btnCancel.Te xt = resources.GetSt ring("btnCancel .Text")

Me.btnCancel.Te xtAlign = CType(resources .GetObject("btn Cancel.TextAlig n"),
System.Drawing. ContentAlignmen t)

Me.btnCancel.Vi sible = CType(resources .GetObject("btn Cancel.Visible" ),
Boolean)

'

'btnSave

'

Me.btnSave.Acce ssibleDescripti on =
CType(resources .GetObject("btn Save.Accessible Description"), String)

Me.btnSave.Acce ssibleName =
CType(resources .GetObject("btn Save.Accessible Name"), String)

Me.btnSave.Anch or = CType(resources .GetObject("btn Save.Anchor"),
System.Windows. Forms.AnchorSty les)

Me.btnSave.Back groundImage =
CType(resources .GetObject("btn Save.Background Image"), System.Drawing. Image)

Me.btnSave.Dock = CType(resources .GetObject("btn Save.Dock"),
System.Windows. Forms.DockStyle )

Me.btnSave.Enab led = CType(resources .GetObject("btn Save.Enabled"), Boolean)

Me.btnSave.Flat Style = CType(resources .GetObject("btn Save.FlatStyle" ),
System.Windows. Forms.FlatStyle )

Me.btnSave.Font = CType(resources .GetObject("btn Save.Font"),
System.Drawing. Font)

Me.btnSave.Imag e = CType(resources .GetObject("btn Save.Image"),
System.Drawing. Image)

Me.btnSave.Imag eAlign = CType(resources .GetObject("btn Save.ImageAlign "),
System.Drawing. ContentAlignmen t)

Me.btnSave.Imag eIndex = CType(resources .GetObject("btn Save.ImageIndex "),
Integer)

Me.btnSave.ImeM ode = CType(resources .GetObject("btn Save.ImeMode"),
System.Windows. Forms.ImeMode)

Me.btnSave.Loca tion = CType(resources .GetObject("btn Save.Location") ,
System.Drawing. Point)

Me.btnSave.Name = "btnSave"

Me.btnSave.Righ tToLeft = CType(resources .GetObject("btn Save.RightToLef t"),
System.Windows. Forms.RightToLe ft)

Me.btnSave.Size = CType(resources .GetObject("btn Save.Size"),
System.Drawing. Size)

Me.btnSave.TabI ndex = CType(resources .GetObject("btn Save.TabIndex") ,
Integer)

Me.btnSave.Text = resources.GetSt ring("btnSave.T ext")

Me.btnSave.Text Align = CType(resources .GetObject("btn Save.TextAlign" ),
System.Drawing. ContentAlignmen t)

Me.btnSave.Visi ble = CType(resources .GetObject("btn Save.Visible"), Boolean)

'

'DataSetConfigu ration

'

Me.DataSetConfi guration.DataSe tName = "ConfigurationD ataSet"

Me.DataSetConfi guration.Locale = New
System.Globaliz ation.CultureIn fo("en-US")

'

'Configuration

'

Me.AccessibleDe scription =
CType(resources .GetObject("$th is.AccessibleDe scription"), String)

Me.AccessibleNa me = CType(resources .GetObject("$th is.AccessibleNa me"),
String)

Me.Anchor = CType(resources .GetObject("$th is.Anchor"),
System.Windows. Forms.AnchorSty les)

Me.AutoScaleBas eSize = CType(resources .GetObject("$th is.AutoScaleBas eSize"),
System.Drawing. Size)

Me.AutoScroll = CType(resources .GetObject("$th is.AutoScroll") , Boolean)

Me.AutoScrollMa rgin = CType(resources .GetObject("$th is.AutoScrollMa rgin"),
System.Drawing. Size)

Me.AutoScrollMi nSize = CType(resources .GetObject("$th is.AutoScrollMi nSize"),
System.Drawing. Size)

Me.BackgroundIm age = CType(resources .GetObject("$th is.BackgroundIm age"),
System.Drawing. Image)

Me.ClientSize = CType(resources .GetObject("$th is.ClientSize") ,
System.Drawing. Size)

Me.Controls.Add Range(New System.Windows. Forms.Control() {Me.btnSave,
Me.btnCancel, Me.dtgRegistry, Me.tvRegistry, Me.btnReadRegis try})

Me.Dock = CType(resources .GetObject("$th is.Dock"),
System.Windows. Forms.DockStyle )

Me.Enabled = CType(resources .GetObject("$th is.Enabled"), Boolean)

Me.Font = CType(resources .GetObject("$th is.Font"), System.Drawing. Font)

Me.Icon = CType(resources .GetObject("$th is.Icon"), System.Drawing. Icon)

Me.ImeMode = CType(resources .GetObject("$th is.ImeMode"),
System.Windows. Forms.ImeMode)

Me.Location = CType(resources .GetObject("$th is.Location"),
System.Drawing. Point)

Me.MaximumSize = CType(resources .GetObject("$th is.MaximumSize" ),
System.Drawing. Size)

Me.MinimumSize = CType(resources .GetObject("$th is.MinimumSize" ),
System.Drawing. Size)

Me.Name = "Configurat ion"

Me.RightToLeft = CType(resources .GetObject("$th is.RightToLeft" ),
System.Windows. Forms.RightToLe ft)

Me.StartPositio n = CType(resources .GetObject("$th is.StartPositio n"),
System.Windows. Forms.FormStart Position)

Me.Text = resources.GetSt ring("$this.Tex t")

Me.Visible = CType(resources .GetObject("$th is.Visible"), Boolean)

CType(Me.dtgReg istry, System.Componen tModel.ISupport Initialize).End Init()

CType(Me.DataSe tConfiguration,
System.Componen tModel.ISupport Initialize).End Init()

Me.ResumeLayout (False)

End Sub

#End Region

Private cnnConfiguratio n As SqlConnection

Private daConfiguration As SqlDataAdapter

Private dsConfiguration As DataSet

Private drConfiguration As SqlDataReader

Private Sub Configuration_L oad(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load

'Expand the tree view

tvRegistry.Expa ndAll()

End Sub

Private Sub InitializeTable ()

Dim index As Integer

Dim objRegKey As RegistryKey

Dim sKeyValue As String

objRegKey = Registry.LocalM achine.OpenSubK ey("Software\da tabase\emailinf o",
True)

sKeyValue = objRegKey.GetVa lue("FromName", "AAA")

' Create a DataTable named "Registry Data".

dataTable = New DataTable("Regi stryData")

' Create columns in the DataTable.

addColumns()

AddNewRow("Comp any", "REG_SZ", "OCS")

AddNewRow("Emai lID", "REG_SZ", "a@b.com")

AddNewRow("Erro rEmailID", "REG_SZ", "te************ @ocs.com")

AddNewRow("From Name", "REG_SZ", sKeyValue)

AddNewRow("Reci pientEmail", "REG_SZ", "fa******@aaa.c om")

AddNewRow("Rese ndInterval", "REG_DWORD" , "3e80")

AddNewRow("Rese ndLimit", "REG_DWORD" , "2")

AddNewRow("Send erEmail", "REG_SZ", "pd*****@aaa.co m")

AddNewRow("WebM aster", "REG_SZ", "Te************ @ocs.com")

End Sub

Private Sub addColumns()

dataTable.Colum ns.Add("Name", Type.GetType("S ystem.String"))

dataTable.Colum ns.Add("Type", Type.GetType("S ystem.String"))

dataTable.Colum ns.Add("Data", Type.GetType("S ystem.String"))

End Sub

Private Sub AddNewRow(ByVal StringName As String, ByVal StringType As
String, ByVal StringData As String)

Dim dataRow As DataRow

dataRow = dataTable.NewRo w()

dataRow(0) = StringName

dataRow(1) = StringType

dataRow(2) = StringData

dataTable.Rows. Add(dataRow)

End Sub

Private Sub tvRegistry_Afte rSelect(ByVal sender As System.Object, ByVal e As
System.Windows. Forms.TreeViewE ventArgs) Handles tvRegistry.Afte rSelect

Dim sSelectedNode As String = tvRegistry.Sele ctedNode.Text

dtgRegistry.Cap tionText = tvRegistry.Sele ctedNode.FullPa th

If StrComp(UCase(s SelectedNode), "EMAILINFO" , CompareMethod.T ext) = 0 Then

' Create a DataTable of data to use for Registry Data.

InitializeTable ()

' Bind the DataGrid to the DataTable.

dtgRegistry.Dat aSource = dataTable

Else

If Not IsNothing(dataT able) Then

dataTable.Clear ()

End If

End If

End Sub

Private Sub btnSave_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles btnSave.Click

Dim objRegKey As RegistryKey

Dim sKeyValue As String

Dim sSelectedNode As String

sSelectedNode = tvRegistry.Sele ctedNode.FullPa th

sSelectedNode = Mid(sSelectedNo de, Len("HKEY_LOCAL _MACHINE\") + 1)

MessageBox.Show (sSelectedNode)

objRegKey = Registry.LocalM achine.OpenSubK ey(sSelectedNod e, True)

'read data from the data grid and write it to the registry

MessageBox.Show (dsConfiguratio n.Tables(0).Col umns.Count)

'sKeyValue = objRegKey.GetVa lue("FromName", "HP")

End Sub

End Class

"scorpion53 061" <sc************ @yahoo.com> wrote in message
news:Oc******** ******@TK2MSFTN GP10.phx.gbl...
Please post this code you are using to fill a datagrid from a datatable.

"Tejpal Garhwal" <te************ @ocs.com> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
My Datagrid is bound to Datatable which i am creating and populating the
datagrid with this datatable at the run time.

"William Ryan" <do********@com cast.nospam.net > wrote in message
news:Om******** ******@TK2MSFTN GP11.phx.gbl...
Everything you can bind the grid to, a collection, datatable,
dataview,
and
even dataset, will have something that's enumerable and can be

counted...it
depends what you are binding to.

DataTable.Rows. Count should work as Mr. B mentioned unless you are binding to something else. What is the grid bound to? If a DataView, then
Dataview.rows.c ount. If a strongly typed collection then
Collection.Item s.Count.

HTH,

Bill
"Tejpal Garhwal" <te************ @ocs.com> wrote in message
news:OY******** ******@TK2MSFTN GP10.phx.gbl...
> Thanks Bruce, but your code with return the row count of Datatable

not the
> DataGrid. I need the row count for DataGrid.
>
> I know you have the answer for this too :)
>
> "Tejpal Garhwal" <te************ @ocs.com> wrote in message
> news:uL******** ******@TK2MSFTN GP09.phx.gbl...
> > I have datagrid filled with some data rows. At the run time i want

know
> how
> > many total rows are there in the data grid ?
> >
> > Any idea ? Any Suggestions ?
> >
> > Thanks in advance
> >
> > Tej
> >
> >
>
>



Nov 20 '05 #7

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

Similar topics

1
2443
by: Brian Anderson | last post by:
Hello, I am creating a windows application with a data grid contained on it. I want to find out the number of columns contained in the data grid at runtime, but I am not sure how to do this. I know that when using ASP.NET the data grid control has a class called datagrid.columns.count that does this, however the windows data grid control...
2
2013
by: kk | last post by:
Have 2 problems, any help is appreciated. Tab with Grids -------------- BL - fetching data from DB ( 5 secs - 10 rows) Grid Laod - 20 secs Grid Paint on tab change - 20 secs Problem: The data fetch only takes 5 secs, why does paint and load take 40 secs in total.
1
5098
by: Da-Breegster | last post by:
Hi. I'm attempting to write a roguelike (think nethack, crawl, angband, tome, adom, and yes, I suppose even rogue) in Perl and I've ran into a problem regarding the data structure for the map and handling it easily. A map is one 2D level, a simple grid. Each tile on the grid will be a hash of data about the grid. The map object itself has...
2
2489
by: Josef Meile | last post by:
Hi, I'm using a ComboBox, some Textboxes, and a DataGrid to represent a many-to-many relationship between Person and Course. Each time that I change the value in the ComboBox (which for now is the OID of Person), the information of the person matching the selected OID is shown in the Textboxes (Name, Address, id, etc) and the courses this...
6
2358
by: Darrell Wesley | last post by:
Is there any way to copy an entire row from the Data Grid and then Paste it into a new row, modify some data and then save it back to the database? This grid is bound to a dataadapter with a commandbuilder monitoring the activity. Is there some property setting that needs to be set or what?
0
4152
by: Gian Paolo | last post by:
this is something really i can't find a reason. I have a form with a tabcontrol with tree pages, in the second page there is a Data GRid View. Plus i have a class. When i open the form i "inizialize" the Data Grid View (add a data sorce, filled with notthing at staratup, and hide some columns) when i put a code in the txtCLCOD textbox start a...
9
4000
by: Anil Gupte | last post by:
After reading a tutorial and fiddling, I finally got this to work. I can now put two tables created with a DataTable class into a DataRelation. Phew! And it works! Dim tblSliceInfo As New DataTable("SliceInfo") Dim tblSliceRatings As New DataTable("SliceRatings") '.... All the adding datacolumns, datarows, etc. goes here.. ...
0
4316
by: Adam Sandler | last post by:
Hello, Prior to posting I looked at http://groups.google.com/group/ microsoft.public.dotnet.framework.aspnet/browse_thread/thread/ d8d5ae243614085e/d4fd6c4a5aa56f75 http://groups.google.com/group/microsoft.public.dotnet.framework.aspnet/browse_thread/thread/abb4bcc39312a388/2de51eba9a0bcfd6 Hello,
3
1708
by: =?Utf-8?B?UGF1bA==?= | last post by:
Hi I have a generic list of data list <typelistcategory; listcategory = new list <type>; I also have a dropdown box that I have put into a template column of a gridview. I was able to populate the dropdown box ok when it was outside of the gridview for (int i = 0; i <= listcategory.Count - 1; i++) {...
0
7467
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7656
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. ...
0
7807
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7419
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7756
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...
0
5971
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...
0
4944
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...
0
3442
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1014
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.