|
-
June 27th, 2005, 03:35 AM
#1
Datagrid Row heading
Can we set the RowHeading to datagrid rows?
If Yes, kindly help me in how to do it or how to freeze the first column of the grid.
Or how can we freeze the column of the datagrid?
Thanks
Last edited by AmitInnani; June 27th, 2005 at 04:35 AM.
-
June 28th, 2005, 05:30 AM
#2
Re: Datagrid How heading
DataGridColumnStyle.HeaderText property is what you are looking for.
This is taken from MSDN:
Code:
Private Sub SetHeaderText()
Dim dgCol As DataGridColumnStyle
Dim dataCol1 As DataColumn
Dim dataTable1 As DataTable
dgCol = dataGrid1.TableStyles(0).GridColumnStyles(0)
dataTable1 = dataSet1.Tables(dataGrid1.DataMember)
dataCol1 = dataTable1.Columns(dgCol.MappingName)
dgCol.HeaderText = dataCol1.Caption
End Sub 'SetHeaderText
(If I helped you, Rate ThisPost is much appreciated)
-
June 29th, 2005, 01:22 AM
#3
Re: Datagrid How heading
Thanks
But this will set the column heading, I want to set the Row Heading i,e Fixed column on Left Hand Side.
-
June 29th, 2005, 03:06 AM
#4
Re: Datagrid How heading
I didn't understand what you need.
Here is an example of how to put the row number in the Grid row. You will need to inherit from the DataGrid and implement the OnPaint method:
Code:
Private Sub MyGrid_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
Try
Dim row As Integer = 0
Dim yDelta As Integer = GetCellBounds(row, 0).Height + 1
Dim y As Integer = GetCellBounds(row, 0).Top + 2
Dim cm As CurrencyManager = CType(BindingContext(DataSource, DataMember), CurrencyManager) '
While ((y < Height - yDelta) And (row < cm.Count))
Dim text As String = String.Format("{0}", row + 1)
e.Graphics.DrawString(text, Me.Font, New SolidBrush(Color.Black), 12, y)
y += yDelta
row += 1
End While
Catch ex As Exception
Finally
End Try
End Sub
(If I helped you, Rate This Post is much appriciated)
-
June 29th, 2005, 05:49 AM
#5
Re: Datagrid Row heading
Thanks it worked.
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
|