Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi folks,

does anybody know if it is possible or how to change the symbol/add text to the datagrid rowheader. I am not using navigation but I am using filters to modify the data displayed based on the row selected and its contents. I would like to add some more intutive for the user like '+' or '-' or text.

 

Thanks:D

Hamlet
Posted
You can use ItemCreated event and check if e.Item.ItemType = ListItemType.Header

A man and a dog have an average of three legs.

Beaware of Statistics.

Posted

Hi Hrabia,

I am not too sure what you are talking about here, I need to look at it further. I have found an example at

 

http://www.syncfusion.com/FAQ/WinForms/FAQ_c44c.asp#q896q

 

that allows me to put text in the header row, but this only paints it at a certain point and is not actually in the row header. If I re-size the rows it does not work.

 

If you have any mor info on your suggestion, pass it on.

 

Slan

Hamlet
Posted

Hi folks,

I have managed to solve the row re-size problem by modifiying the "dataGrid1_Paint" part of the sample at http://www.syncfusion.com/FAQ/WinFo..._c44c.asp#q896q

I have adjusted it to use the cell location element instead of the ydelta variable to ensure that the text is drawn at the start of the appropriate row, even if the row is re-sized. This means the OnMouseDown/Up methods do not have to be modified. In the example below I have also modified it to display different text based on the contents of cells in the row, this could be changed to suit any different needs.

 

 

 

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

 

 

If anybody has any further/better suggestion on how to do this, please pass them on.

Hamlet
  • 1 month later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...