Add column in ObjectListView 2.5, SharpDevelop 4.1 (Windows7) crash designer

1k Views Asked by At

Adding a column using the designer crashes the control with the following message:

System.Exception: The control BrightIdeasSoftware.ObjectListView has thrown an unhandled exception in the designer and has been disabled.  
Exception: Unable to cast object of type 'System.Windows.Forms.ColumnHeader' to type 'BrightIdeaSoftware.OLVColumn'

I tried 2 different laptops. On both machines it works fine with VS2010 but crashes the designer in #D

Then I make a fresh install of windows7, .net4, sdk and OLV using VirtualBox in a linux box with the same result.

Can't find useful information in Google so I appreciate any help with this.

3

There are 3 best solutions below

0
On

It is a bug. SharpDevelop is not using the custom column collection editor that the ObjectListView assembly contains. Instead it is defaulting to the column collection editor which is used for the standard System.Windows.Forms.ListView.

0
On

You can just go into the designer code and change the column type from System.Windows.forms.Column to new BrightIdeas.OLVColumn and make sure your columns are also declared as such - after this you can then edit the columns.

0
On

I had same problem in c#. I use SharpDevelop 4.3.3 and c# 4. I just solved following this step:

  • Add object list view (i.e. objectListView1) in the form
  • Add olvColumns (i.e. olvColumn1, olvColumn2, etc...) directly in the form... without using column editor.
  • In the InitializeComponent method of the form (that is called in the constructor of the form), after initialization of olvColumns, add link between object list view and column after the code

    [...]
    // 
    // olvColumn4
    // 
    this.olvColumn4.CellPadding = null;

    // after initialization of olvColumns 

    objectListView1.Columns.Add(olvColumn1);
    objectListView1.Columns.Add(olvColumn2);
    objectListView1.Columns.Add(olvColumn3);
    objectListView1.Columns.Add(olvColumn4);

    [...]

After this operations, you can reopen form in design mode and check objectlistview columns: you will see there are columns that you created.