We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

+/- buttons visible when they shouldn''t be

I''m using a GridDataBound control to display some hierarchical data. This data can be up to 10 levels deep, and is user-configured. My method is to first determine how many datatables I need (1 for each level of the hierarchy), create the datatables, put them into a dataset, and setup the relationships in the dataset. Then I bind the dataset to the grid. This all works fine, except for one slight cosmetic problem, which is nonetheless annoying. My grid is displaying the +/- button on every row of the grid, even if there are no ''child'' items for that row. Clicking the +/- button either does nothing, or makes the button disappear. Since there are no children, the button should not appear at all. I have "ShowTreeLines" set to true, and "IndentHierarchies" also set to true. Am I missing something? Is there a way to make those buttons that do nothing, invisible, as they should be?

14 Replies

AD Administrator Syncfusion Team March 7, 2005 10:07 PM UTC

If you have ShowTreeLines = true, then try handling the CellDrawn event using code like:
    Private Sub gridDataBoundGrid1_CellDrawn(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.GridDrawCellEventArgs)
        If e.ColIndex = 2 Then
            Dim state As GridBoundRecordState = Me.gridDataBoundGrid1.Binder.GetRecordStateAtRowIndex(e.RowIndex)
           If state.HasChildList And state.ChildCount = 0 Then
                Dim count As Integer

                If state.Position >= state.Table.Count Then
                    count = 0 ''add row...
                    count = state.ChildCount
                End If
            End If
        End If
    End Sub ''gridDataBoundGrid1

JE Jan Eugenides March 7, 2005 10:15 PM UTC

That works, most of the time...it''s better. But if I repeatedly expand and collapse a row, and the underlying row(s) are not expandable themselves, I sometimes get [-] in front of the rows, instead of nothing. Mousing over the [-] makes it disappear, so it''s like a ghost. We''re close though! Can you think of any refinements?

JE Jan Eugenides March 7, 2005 10:29 PM UTC

Hmm.. I replaced the Invalidate(e.bounds) with a simple Invalidate(), and now it works in all cases (I sometimes see a slight flash of the buttons but I can live with it :) ) Thanks for the help.

AD Administrator Syncfusion Team March 7, 2005 10:54 PM UTC

You might try Me.gridDataBoundGrid1.Invalidate(e.Bounds) Me.gridDataBoundGrid1.Update()

TO Tomas November 16, 2005 12:45 PM UTC

I have tried this and and don''t get the code working when I have ShowTreeLines = true at all. When I try the nodes are expanded but showing "minus" instead of nothing for the empty nodes. If I set ShowTreeLines = false and IndentHierarchies = true I get the same phenomena as above. The only way I get this to work is to have both ShowTreeLines and IndentHierarchies set to false, but that doesn''t look to good. Any ideas of how I can get it working with either TreeLines or at least having the rows indented?

AD Administrator Syncfusion Team November 16, 2005 01:49 PM UTC

If you are using 3.3, there is a defect that is causing the buttons to show up when they should not. http://www.syncfusion.com/support/issues/grid/Default.aspx?ToDo=view&questId=872 This has been corrected in our code base, but the correction is not available in a public release yet. If you need something before it becomes available, you can submit a directtrac support incident and request a private build.

TO Tomas January 30, 2006 01:56 PM UTC

I have now upgraded to the latest version of the grid (v4.1.0.50) and I still have problems. The plus/minus signs seem to behave the way they should in this version but the Invalidate(e.Bounds) row seems to update more than just the grid-row. Other parts of the form, especially a toolbar control we use, get misdrawn and almost disappeared and also some button controls. It looks like a grey rectangle gets drawn on top of those controls, or they simply don''t get drawn at all. I had the same problem in the 3.3 version and was hoping that upgrading would remove them. If I remove the invalidate(e.Bounds) row the graphic errors are gone, but of course the plus/minus signs start to misbehave instead. What could be causing those graphical errors? I have ShowTreeLines set to true and IndentHierarchies set to false.

ST stanleyj Syncfusion Team January 30, 2006 03:35 PM UTC

Hi Tomas, The bug #872 in 3.3 is definitely corrected, can you help us reproduce the odd behavior in this sample? Regards, Stanley

TO Tomas January 31, 2006 12:28 PM UTC

I wasn''t able to get the behaviour in your solution, so I extracted a small part of my application instead to show it. The toolbar control, labels and buttons seem to have this drawing error. If you move the window immediately after starting the graphical error disappears, but still if you click the cancel button you will see that the button doesn''t work as it should (doesnt switch to "pushed down" image) All those strange things disappear the same moment as I comment the row: this.gridDataBoundGrid1.Invalidate(e.Bounds); Maybe i''m missing something here, but it feels pretty strange. /Tomas


ST stanleyj Syncfusion Team January 31, 2006 01:13 PM UTC

Hi Tomas, Try replacing these existing codes this.gridDataBoundGrid1.EndUpdate(); this.gridDataBoundGrid1.Invalidate(e.Bounds); to this.gridDataBoundGrid1.InvalidateRange(GridRangeInfo.Row(e.RowIndex)); this.gridDataBoundGrid1.EndUpdate(); Best regards, Stanley

TO Tomas January 31, 2006 01:34 PM UTC

Thanks for your quick reply Stanley, but unfortunately that won''t help me either since this makes the original problem to come back which is showing + signs even for the empty nodes. Those + signs are shown until I do a "mouse over" with the pointer and then they disappear (except for the ones that really have nodes underneath of course) Do you have any other ideas what might cause this? /Tomas

ST stanleyj Syncfusion Team February 1, 2006 05:51 AM UTC

Hi Tomas, Sorry for the wrong codes I sent earlier, bit excited to see all controls proper. With the help of your UI design, I was also able to reproduce in the sample that I uploaded earlier. The problem is based on the panels used, now in your sample, a panel is added underneath all the panel and controls. There seems to be no trouble regarding graphical error. Let me know if you still find any problems. Best regards, Stanley

TO Tomas February 2, 2006 07:53 AM UTC

I''m impressed that you got it to work Stanley! I tried the sample you have modified and saw that it really works. but.. (there''s always a but isn''t it) When I try to make this change in my "real" application I still get the same graphical errors. Desperately I created a completely new form without adding any special UI, dragged in a toolbar, a grid and 2 buttons but still the errors are there. Could you try to explain what steps you made to get rid of this? Me adding a panel and put the other controls in that panel doesn''t seem to help. Big thanks for your efforts trying to help! /Tomas

ST stanleyj Syncfusion Team February 2, 2006 10:07 AM UTC

Hi Tomas, I am sure, you will not encounter this problem if a panel is added first all the controls later to it. Without using a panel for the grid there is no trouble, directly adding all controls to the form. Best regards, Stanley

Live Chat Icon For mobile
Up arrow icon