This post is in two parts:
a) a suggestion for new column widths functionality
b) a request for how to extend the grid in 1.5 to have this functionality.
I'd like to be able to quickly define the column widths for bound grids in a similar fashion to HTML table column widths i.e. a combination of pixel and percentage specifications.
It would be handy to have the following properties on a GridBoundColumn:
a) Width. The specification of width in pixels for a column.
b) WidthPercentage. The specification of width as a percentage of the total table width (0-100%).
If neither the Width or WidthPercentage is specified then the column width behaviour is as per the V1.5 grid functionality.
If Width is specified, but WidthPercentage is not, then the Width value in pixels is used for the column widths.
If WidthPercentage is specified, then the Width is treated as a minimum width specification.
If the sum of all the (minimum) Width pixel values is greater than the grid control width then the Width percentage functionality is not active. A horizontal scroll bar would be present.
If the sum of the minimum pixel widths is less than the grid control width then horizontal scroll bars are not needed and the Width percentage functionality kicks in based on a percentage of the grid control width.
Resizing the grid control width would automatically adjust the size of the % specified columns and display a horizontal scroll bar if necessary.
I'm sure this suggestion has plenty of holes in it, but it does present an idea for an intuitive means of defining column widths dynamically which make sense visually to the user but doesn't require a traversal of the row data. The intent is to look at possibilities for improving the Essential Grid column width related functionality.
What do you think?
If I wanted to implemented this sort of functionality could I do this by extending the 1.5 version of the grid and still have it configurable from the VS.NET designer property pages?
ADAdministrator Syncfusion Team March 9, 2003 03:13 PM
thanks for the detailed suggestions. We'll add a similar functionality in the 2.0 version.
For now you could sure also implement such functionality based on the 1.5 code base. You could either derive your own grid control or simply just handle various events in the grid that are called when the grid is resized and when the grid is initially setup.
First, for databound grid make sure you set AllowResizeToFit = false.
To initialize the column widths for the first the time before the grid is shown, you could do this in your forms OnLoad method.
To reinitialize column widths after the grid was resized you should handle the Layout event.
To detect if any column widths have been changed explicitly by the user handle ColWidthsChanged event.
AIApolon IvankovicMarch 9, 2003 07:20 PM
Thanks for the info on column resizing extension approach.
I have a need for a number of extensions to the essential grid needed for my typical development work scenarios. Most are oriented around databound grids and being able to extend column related functionality. I'd prefer to make the extensions configurable rather than having to code the extensions for every individual grid implementation.
The main piece of the puzzle I'm missing is whether its possible to extend the information present in the GridBoundColumn class to include my app specific properties.
Is there any way to derive from GridBoundColumn and make use the derived class instead (in the designer generated code as well)?
The GridBoundColumnsCollectionEditor class has a protected CollectionItemType property, so presumably the class could be specialized to use a different item type. But then how do you get VS.NET to use a different column collection editor?
ADAdministrator Syncfusion Team March 10, 2003 04:16 AM
You could override the GridBoundColumns property of the GridDataBoundGrid when you derive a class.
[Description("Manages the columns to be displayed in the GridDataBoundGrid.")]
public override GridBoundColumnsCollection GridBoundColumns
base.GridBoundColumns = value;
I hope there are no other internal dependencies inside the grid on GridBoundColumn. I would have to research that first. Let me know if you run into limitations. We can fix that in the grid codebase then for the next minor version.
AIApolon IvankovicMarch 10, 2003 09:49 PM
I tried that and made the MyGridBoundColumnsCollectionEditor type override CreateCollectionItemType and CreateNewItemTypes. Everything compiled and ran without errors, but it still creates Syncfusion.Windows.Forms.Grid.GridBoundColumn fields instead of the specialized type. Any ideas?
Do you know of any good references for using the component model functionality within VS.NET?
ADAdministrator Syncfusion Team March 11, 2003 02:21 PM
In your constructor of MyGridBoundColumnsCollectionEditor you could call the base class constructor passing in the type.
No need to override other methods.
Does this work?
AIApolon IvankovicMarch 11, 2003 05:42 PM
Nope, the Add button gets greyed out when I do that. Attached is a sample project so you can see the code details.
Thanks for taking the time for something thats not completely Essential Grid related i.e. the .NET component model stuff. Its appreciated.
ADAdministrator Syncfusion Team March 12, 2003 06:44 AM
Ok, there seem to be some dependencies inside the grid that are not good for this scenario.
But I'll make some changes so that it will be possible with the 1.6 version. I have your project and will make sure this works then.
JIJianwenOctober 22, 2003 11:45 AM
> Hi Apolon,
> thanks for the detailed suggestions. We'll add a similar functionality in the 2.0 version.
> For now you could sure also implement such functionality based on the 1.5 code base. You could either derive your own grid control or simply just handle various events in the grid that are called when the grid is resized and when the grid is initially setup.
> First, for databound grid make sure you set AllowResizeToFit = false.
> To initialize the column widths for the first the time before the grid is shown, you could do this in your forms OnLoad method.
> To reinitialize column widths after the grid was resized you should handle the Layout event.
> To detect if any column widths have been changed explicitly by the user handle ColWidthsChanged event.
Is this functionality included in 2.0 yet? Can you be more specific about what 2.0 can do?
Here is what we want:
1) Able to specify colWidths and RowHeights as
percentages of grid width and height, respectively.
2) Able to change grid width and height dynamically and each cell with scale itself proportionally according to the specified colWidths and RowHeights.
By the way, when will 2.0 be available?
ADAdministrator Syncfusion Team October 22, 2003 01:24 PM
That I don't think will be in the 2.0 release right away, but further down the road we'll focus on usability and then add such features.
With 2.0 we will have a completely new approach for databound scenarios with our grouping engine and grouping grid and there we really try to use very extensible approaches so that it is easy then to add more features later (and let you customize things to your needs). We'll give more information once the beta is ready.
Thanks for your continued patience!
ADAdministrator Syncfusion Team October 23, 2003 05:58 AM
Forgot to mention that the support for deriving from GridBoundColumns is available with the later 1.6.1.x versions. We also have a sample for that.
ADAdministrator Syncfusion Team October 23, 2003 07:38 AM
I have attached the sample demonstrating deriving from GridBoundColumns. The sample adds a width property, the CustomGridBoundColumn.Width, that
can be used both design time and runtime as long as it is not zero.
It does so by listening to the Model.QueryColWidths event, and if there is
a non zero width value in a column, it provides it in this event.
Subscribing to the event is a little problematic in that you cannot do it in
the grid's constructor as the Model is not fully functional at that point.
So, this sample uses an OnPaint override to subcribe with a flag set to to