|
-
Apr 13th, 2007, 11:16 PM
#1
[2005] Data GridView
Dear All,
How to populate a datagrid manually.
I am doing this
vb Code:
datagridview1.Columns.add("Type","Type)
datagridview1.Columns.add("Age","Age)
Now I want to fill this column manully.That is not from database.How can I
Please mark you thread resolved using the Thread Tools as shown
-
Apr 13th, 2007, 11:32 PM
#2
Re: [2005] Data GridView
Best idea is that you make a datatable and add the column in the datatable and then set the grid datasource to that datatable.
But for your choice you can do like this.
vb Code:
Me.gridSearch.Columns.Add("Type", "Type")
For rowIndex As Integer = 0 To Me.gridSearch.RowCount - 1
Me.gridSearch.Item("Type", rowIndex).Value = "Shakti" 'Any value
Next
'gridSerach is the name of the DataGridView
-
Apr 14th, 2007, 12:19 AM
#3
Registered User
Re: [2005] Data GridView
vb Code:
Private Sub loadGridView()
'dgview as DatagridView control
dgView.Columns.Add("clBookName", "Book Name")
dgView.Columns.Add("clDes", "Description")
dgView.Columns.Add("clDate", "Date")
Dim con As New OleDb.OleDbConnection("type your connection string")
Dim da As New OleDbDataAdapter("type your query", con)
Dim dt As New DataTable
da.Fill(dt)
Dim str() As String = {}
Dim dr As DataRow
If dt.Rows.Count > 0 Then
For Each dr In dt.Rows
For col As Integer = 0 To dt.Columns.Count - 1
str(col) = dr(col).ToString
Next
dgView.Rows.Add(str)
Next
End If
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|