Home - Forums-.NET - FlyGrid.Net (Windows Forms) - Exception adding column to new FlyGrid using form designer

FlyGrid.Net (Windows Forms)

.NET Datagrid - Fast, highly customizable, industry standards .NET data grid control for WinForms

This forum related to following products: FlyGrid.Net

Exception adding column to new FlyGrid using form designer
Link Posted: 16-Oct-2006 17:42
Hi there,

I am evaluating FlyGrid for its usefulness in a non-databound way, and thus wish to be able to add columns to a FlyGrid in the form designer, and then add rows programmatically at runtime.

However, if I add a FlyGrid to a UserControl in the form designer, and then immediately try to add a column to the Columns.Items collection on the brand new FlyGrid control, I get the following exception and the control gets disabled by Visual Studio 2005 (only to subsequently come crashing down when i try to delete the FlyGrid from the form).

System.InvalidCastException: Unable to cast object of type 'NineRays.Windows.Forms.Grids.Column' to type 'NineRays.Windows.Forms.Grids.Column'.
   at NineRays.Windows.Forms.Grids.Columns.[][]9()
   at NineRays.Windows.Forms.Grids.Columns.[][])
   at NineRays.Windows.Forms.Grids.Columns.get_VisibleColumns()
   at NineRays.Windows.Forms.Grids.FlyGridViewPort.GetTotalWidth(Int32 startCol)
   at NineRays.Windows.Forms.FlyGrid.[]9([]8, Graphics, Rectangle)
   at NineRays.Windows.Forms.FlyGrid.[]9(FlyGridViewPort, Graphics, Rectangle)
   at NineRays.Windows.Forms.FlyGrid.[][](PaintEventArgs, FlyGridViewPort)
   at NineRays.Windows.Forms.FlyGrid.OnPaint(PaintEventArgs)...


This happens for all the different types of columns that can be added to the Columns.Items collection.

If I set and then clear the DataSet property to an arbitrary dataset, this problem goes away, but I'm concerned by its presence.

Is adding columns manually in the designer something that I shouldn't be doing? Is there a property I need to set first to make it work without the Dataset set/clear workaround?

Thanks in advance for your help...

Cheers,

Dave.
Link Posted: 17-Oct-2006 00:31
To solve this problem, please see the one of the FlyGrid.Net Video Tutorials that help you to familiarize with FlyGrid:
Your First FlyGrid.Net App
Other video tutorials you can find on the FlyGrid.Net product page (Video Tutorials section)
Link Posted: 17-Oct-2006 04:13
[quote="NineRays"]To solve this problem, please see the one of the FlyGrid.Net Video Tutorials that help you to familiarize with FlyGrid:
Your First FlyGrid.Net App
Other video tutorials you can find on the FlyGrid.Net product page (Video Tutorials section)


Thanks for the suggestion, though the tutorials weren't what I needed - I'm using custom control libraries all the time

It turns out that the problem was related to two identical versons of the FlyGrid DLLs being used from two different paths.

I had copied the NineRays DLLs  to my custom library path, which was referenced by the project, and that's the version I added to the toolbox, but Visual Studio was picking up the versions installed in the default FlyGrid install path instead, for all but NineRays.FlyGrid.dll itself, which was correctly referenced from the path I'd selected. That seemed (understandably) to confuse the form designer.

I just need to remove all traces of the c:/Program Files/FlyGrid.Net/Bin/Net2.0 version and ensure all references are to my alternative library path, and everything should work perfectly.

The component is great, by the way... nice work, 9rays!

Dave.
Link Posted: 17-Oct-2006 04:23
It turns out that the problem was related to two identical versons of the FlyGrid DLLs being used from two different paths.

Video tutorials provide the ways of referencing to FlyGrid.Net assemblies that prevent from \"dll hell\", especially when you work in design-mode, as Visual Studio IDE automatically resolves references to the assemblies that can can cause problem with types.
Link Posted: 19-Dec-2007 13:30
The Video Tutorials solved many problems.
Thanks!