I have a form on which I have two GridListControls. In both cases, there is no assigned datasource. Instead, I am treating the contained grid control as a virtual grid via the Queryxxx methods.
On my machines, as well as some others, this works perfectly. However, on a couple other machines, the Queryxxx methods are never called for the contained grid controls resulting in an empty list display.
All machines in question are running XP pro, and all machines are running the exact same build.
This is a tricky problem because I cannot duplicate it myself. We determined that the Queryxxx methods are not being called because another developer does have the problem and was able to debug and place some breakpoints which are never hit in the Queryxxx methods.
I thought to just convert the controls to use a Datasource, although that gives me less control. And I will try that.
But in the meantime, is there anything you know that might be causing this problem?
ADAdministrator Syncfusion Team January 26, 2005 11:05 AM
If it is the exact same code running code (ie same exe + same syncfusion dll''s), then I am at a loss.
One general reason that events may not be hit are the problems arising due to dynamic splitters. But such problems do not normally vary from system to system if the same code is running. Here is a KB on using events with dynamic splitters. http://22.214.171.124/Support/article.aspx?id=580
ADAdministrator Syncfusion Team January 26, 2005 02:21 PM
I looked at the KB item you referenced but I don''t think it applies here. There is a splitter control in the form in question, but it''s just a plain old .net splitter control.
Incidentally, this problem occurs with both 126.96.36.199 and 188.8.131.52. Very strange.
I''ll see if I can put together a sample app that duplicates the problem. I''ll send it to the people on whose machines the problem exists and if they still see the same problem, I''ll forward the sample app over to you to see if you can duplicate it.
ADAdministrator Syncfusion Team January 27, 2005 04:14 PM
I have not yet put together a sample app to send. In the meantime, I commented out the Queryxxx methods and just made the GridListControl''s DataSource point at my ArrayList of objects. Then sent a build to one of the people on who''s machine the GLC was showing up empty before. With "direct data-binding", it worked.
So the problem seems to have something to do with using a virtual grid within a GLC.
This gives me more information but doesn''t really solve my problem entirely because I need to have greater control over the column labels and order of columns in the GLC which direct data-binding is not providing me. Or at least, I don''t know how to control those things via direct data-binding.
Incidentally, I tried to use the Bindable(false) attribute on one of the properties of my "business object" contained in the array list. I was sort of hoping that that attribute would be respected by the GLC''s binding logic, and would hide that property from the GLC, but it doesn''t work. This leads me to wonder if you guys would find it worthwhile to support some custom attributes we can use with properties to help in data-binding w/Syncfusion controls.
For example, to make a property of my business object visible in the control, to make it the 3rd column, and to provide a nicer column label):
public string LongName
The "BindingOrder" would be problematic I guess, the user could quite easily provide values that don''t make sense (leaving gaps and so forth). But maybe we can have a class-level attribute that specifies that we want the binding order to be the order the attributes physically appear in the class rather than alphabetical as it seems they are bound now. Although perhaps reflection doesn''t keep that information around.
I am still quite a neophyte at C# and .net programming (at least compared with C++ and WinSDK stuff). So it could be that there is already something along these lines already provided.
ADAdministrator Syncfusion Team January 27, 2005 05:09 PM
You can control the display order of the proerties in your ArrayList objects by having your ArrayList implement ITypedList. Here is a forum thread that has sample code.
In the GetItemsProperties, get the default property order using the techinque shown in this forum thread. But before returning the collection, reorder the colection to the order you prefer.
ADAdministrator Syncfusion Team January 27, 2005 06:16 PM
I implemented the ITypedList as suggested. That gets me the correct sort order. I''m now looking for ways to modify the column label for the given property (i.e. turn "ShortName" into "Name").
The MemberDescriptor.DisplayName member looked promising but I''m not sure if that''s what you guys use when adding column labels or if you just go by MemberDescriptor.Name. Also, it''s not entirely clear to me how I can set the DisplayName member anyway since it''s a read-only property, there''s no constructor arguement for it and it doesn''t appear to be set via an attribute (like Description is, for instance).
ADAdministrator Syncfusion Team January 28, 2005 01:04 AM
To control the header text, you will have to handle some event. GridListControl.Grid.QueryCellInfo should work, or GridListControl.Grid.DrawCellDisplayText as shown below.
ADAdministrator Syncfusion Team January 31, 2005 10:14 AM
Your suggestion to implement ITypedList spurred me to find out more about the whole .net binding mechanism (and reflection) over the weekend. After discovering the various moving parts involved in binding, I wrote some classes that allow me to use attributes to control the display of class properties when bound to the Syncfusion grid (or any other complex binding control).
I have a CustomBindableArrayList that implements ITypedList and can be parameterized over the contained data-type (i.e. the class object to which I want a control to bind).
I also have a CustomPropertyDescriptor that inherits from PropertyDescriptor. My derived version allows me to associate a custom name for any property of a class. That attribute is "discovered" via reflection by my CustomBindableArrayList''s ITypeList GetItemProperties method.
Finally, I had to create a CustomPropertyNameAttribute attribute that targets properties and allows the association of a string (the custom property name) with any property of a class.
I''m also adding support for a class-targetted property that allows me to specify in what order the properties in that class should appear to any bound control. This lets me easily customize the order of the columns in a grid control bound to an ArrayList of class objects.
I did have to write a bit of code to get all this to work right, and I''m sure I still have a few kinks to work out, but it''s a generic solution applicable to any "business object" I want to bind to a grid while still retaining easy control over what is displayed.
I realize that I could control all this programmatically through the grid, but it just seems simplier to assign a couple attributes to the class.
Incidentally, there is a very simple way to "hide" columns from being bound. The [Browseable(false)] attribute is respected by various .net framework controls as well as by the GridListControl (at least, and I''m guessing Grids and GridDataBoundGrids as well).
That''ll work "right out of the can" without any need to implement ITypedList and so forth.
The end result of all this is that I can bind an ArrayList of Customer objects (for example) to a grid and although the grid wants to display the columns as: Address, Id, ShortName, I can easily (by applying 3 attributes) make the grid display "Id", "Name", "Street Address" or whatever else I want.
To the grid control, those overridden property names are the actually property names - so I have no further event handling or coding do to in the grid to make it work.