. Introduction The TreeGridView by Mark Rideout is a great control. It allows us to display related data in a hierarchical form (a tree!), but I needed it to be sortable and support data binding. The HierarchicalGrid does that, the quick and dirty way. It displays the table relations in a hierarchical form and sorts it through the levels too.
Also, this is my first contribution and any feedback would be greatly appreciated! Background I would really recommend you see the TreeGridView. Using the code There's a new class called DataGridSource, and the DataSource of the HierarchicalGrid must be of that type. It takes three arguments: the dataset, a list of display columns and a list of group columns. Now, what are those?
The display columns are names of the table columns to be displayed, and the group columns are columns that group total values, like sum, average, product, etc. Let's suppose that we have two tables, one with a list of people and their fruit preference, and another with where and when each person bought their favorite fruit. For instance, the display columns would be: List displayColumns = new List; displayColumns.Add( ' id'); displayColumns.Add( ' Name'); displayColumns.Add( ' Fruit'); displayColumns.Add( ' BoughtFrom'); displayColumns.Add( ' Date'); Now we have a list of columns to be displayed. What about the group columns? Let's set them: List groupColumns = new List; groupColumns.Add( new GroupColumn( ' Quantity', GroupTypeEnum.Sum)); Pay attention to the GroupColumn type. It groups the name of the column and the type of operation that it should do on its child results.
We will enter these hierarchical entries into the DataGridView. Now for the coding part. First of all we have to enter the columns into the DatGridView.
We added a new sum of quantities. We have our display columns list and our group columns list. Let's get our dataset.
There is a combination of two things going on to create this error: 1) the IsAssignableFrom is being used in reverse. Line 264 Should read: if ( typeof(TreeGridCell).IsAssignableFrom(cell.GetType)) instead of: if (cell.GetType.IsAssignableFrom( typeof(TreeGridCell))) The docs for IsAssignableFrom read 'true if c and the current Type represent the same type, or if the current Type is in the inheritance hierarchy of c,' where the call would look like CurType.IsAssignableFrom(c). 2) This only showed up if i didn't include the DataRelation Field as one of the 'displayColumns'. Another symptom was that the children of the top nodes weren't displayed either. Brunobert 27-Apr-10 4:58 27-Apr-10 4:58 I'm trying to use this control in my application. I realized that it just works fine if, in my windows themes configuration, i select the windows xp theme.
If i put in classic windows theme, the control returns me an error Error: 'Visual Styles-related operation resulted in and error because no visual style is currently active' I tried to enable the 'Enable XP Styles' in application properties, but it doesn't work either. My point is, my application can't go down because of a simple theme windows configuration, agree? Thanks a lot.