Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DataGridView Question

Status
Not open for further replies.

lawlegacy

IS-IT--Management
Jun 5, 2006
53
US
I created a datagridview programmatically as follows

dim dg as new datagridview

with dg
.name = "dg"
end with

Now how do I access the rows property of the datagridview control?

I tried me.controls("dg").rows but that give me an incorrect syntax error. 'rows is not a member of system.windows.forms.control'

 
Did you add the datagrid to the controls array of the form?

Me.controls.add(dg)
 
Yes, but it doesnt allow me to access the rows property when I do me.controls("dg").row

me.controls("dg").name works though
 
You can't stay only with the .Rows property..
You will either full reference the cell like:

Code:
        Dim c As DataGridView = CType(Me.Controls("dg"), DataGridView)
        msgbox (c.Rows(...).Cells(...).Value)

or you will loop through the rows, like:

Code:
        For Each r As DataGridViewRow In c.Rows

        Next
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top