setting row header text in datagrid: TopRow() not recognized

M

Mad Scientist Jr

i am trying to set the text of the row header in a datagrid
i found several examples
in all cases the TopRow() property is not recognized by VS.NET
any help appreciated!

VERSION 1
(based on code found at
http://www.syncfusion.com/FAQ/WinForms/FAQ_c44c.asp#q896q
)


Private Sub dataGrid1_Paint(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs)
Dim row As Integer = TopRow()
Dim yDelta As Integer = DataGrid1.GetCellBounds(row, 0).Height
+ 1
Dim y As Integer = DataGrid1.GetCellBounds(row, 0).Top + 2
Dim cm As CurrencyManager =
CType(Me.BindingContext(DataGrid1.DataSource, DataGrid1.DataMember),
CurrencyManager)
While y < DataGrid1.Height - yDelta And row < cm.Count
'get & draw the header text...
Dim [text] As String = String.Format("row{0}", row)
e.Graphics.DrawString([text], DataGrid1.Font, New
SolidBrush(Color.Black), 12, y)
y += yDelta
row += 1
End While
End Sub 'dataGrid1_Paint


VERSION 2

Private Sub dataGrid1_Paint(ByVal sender As Object, ByVal e As
PaintEventArgs)
Dim row As Integer
row = TopRow()
Dim cm As CurrencyManager
cm = CType(Me.BindingContext(Me.DataGrid1.DataSource,
Me.DataGrid1.DataMember), CurrencyManager)
Do While ((row < cm.Count))
'get & draw the header text...
Dim text1 As String
If Len(Trim(Me.DataGrid1(row, 1))) = 2 Or
Len(Trim(Me.DataGrid1(row, 1))) = 5 Then
text1 = "+/-"
Else
text1 = ""
End If
e.Graphics.DrawString(text1, Me.DataGrid1.Font, New
SolidBrush(Color.Red), 12, (Me.DataGrid1.GetCellBounds(row,
0).Location.Y))
row = (row + 1)
Loop
End Sub
 
K

Ken Tucker [MVP]

Hi,

TopRow is a function that was added.
pointInCell00 = New Point((dataGrid1.GetCellBounds(0, 0).X + 4),
(dataGrid1.GetCellBounds(0, 0).Y + 4))

Public Function TopRow() As Integer

Dim hti As DataGrid.HitTestInfo

hti = dataGrid1.HitTest(Me.pointInCell00)

Return hti.Row

End Function



Ken

-------------------

i am trying to set the text of the row header in a datagrid
i found several examples
in all cases the TopRow() property is not recognized by VS.NET
any help appreciated!

VERSION 1
(based on code found at
http://www.syncfusion.com/FAQ/WinForms/FAQ_c44c.asp#q896q
)


Private Sub dataGrid1_Paint(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs)
Dim row As Integer = TopRow()
Dim yDelta As Integer = DataGrid1.GetCellBounds(row, 0).Height
+ 1
Dim y As Integer = DataGrid1.GetCellBounds(row, 0).Top + 2
Dim cm As CurrencyManager =
CType(Me.BindingContext(DataGrid1.DataSource, DataGrid1.DataMember),
CurrencyManager)
While y < DataGrid1.Height - yDelta And row < cm.Count
'get & draw the header text...
Dim [text] As String = String.Format("row{0}", row)
e.Graphics.DrawString([text], DataGrid1.Font, New
SolidBrush(Color.Black), 12, y)
y += yDelta
row += 1
End While
End Sub 'dataGrid1_Paint


VERSION 2

Private Sub dataGrid1_Paint(ByVal sender As Object, ByVal e As
PaintEventArgs)
Dim row As Integer
row = TopRow()
Dim cm As CurrencyManager
cm = CType(Me.BindingContext(Me.DataGrid1.DataSource,
Me.DataGrid1.DataMember), CurrencyManager)
Do While ((row < cm.Count))
'get & draw the header text...
Dim text1 As String
If Len(Trim(Me.DataGrid1(row, 1))) = 2 Or
Len(Trim(Me.DataGrid1(row, 1))) = 5 Then
text1 = "+/-"
Else
text1 = ""
End If
e.Graphics.DrawString(text1, Me.DataGrid1.Font, New
SolidBrush(Color.Red), 12, (Me.DataGrid1.GetCellBounds(row,
0).Location.Y))
row = (row + 1)
Loop
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top