donnacha Posted July 15, 2003 Posted July 15, 2003 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 Quote Hamlet
hrabia Posted July 15, 2003 Posted July 15, 2003 You can use ItemCreated event and check if e.Item.ItemType = ListItemType.Header Quote A man and a dog have an average of three legs. Beaware of Statistics.
donnacha Posted July 15, 2003 Author Posted July 15, 2003 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 Quote Hamlet
donnacha Posted July 16, 2003 Author Posted July 16, 2003 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. Quote Hamlet
donnacha Posted July 16, 2003 Author Posted July 16, 2003 Hi folks, that link I posted should be to topic 5.57 How can I place text in the rowheader column of my datagrid? see http://www.syncfusion.com/FAQ/WinForms/FAQ_c44c.asp#q896q Quote Hamlet
kostermw Posted August 30, 2003 Posted August 30, 2003 ThanX Exactly what I was looking was! Saved me a lot of trial/error work. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.