Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
115
Order and header's caption in column grid when binding to custom datasource
posted

Hi,

I'm binding a grid to a custom datasource. My problem is that columns don't appear exactly as i'd like.

I can't set order and header's caption to columns, as well as, to decide which columns to be shown and which not.

  • Order

It seems property order declaration inside the object doesn't determine columns order. So how do I change it?

  • Caption

Wingrid Maps column names to property names. Is there a way of changing it?

  • Choosing visible columns

I think WinGrid only shows public object properties. I do inherit all my business objects and i don't want to show base class public properties in the grid neither some of the object itself. Again, Does any body knows something about it?

 Thanks

Parents
  • 115
    posted

    I found the solution.

    Every public object property (get/set) becomes a WinGrid Column with caption equals to property name. In order to set a custom caption  you must add System.ComponentModel.DisplayName's attribute to the property. 

     For instance,

    Protected int? mCellNum = null

    [System.ComponentModel.DisplayName("Cell phone")]

    public int? CellNum  {
                    get { return mCellNum ; }
                    set { mCellNum = value; }
    }


    If you don't want to show a specific property,  for example a business ID, add System.ComponentModel.Browsable's attribute to the property.

    For instance, 

    Protected int? mID = null

    [System.ComponentModel.Browsable(false)]

    public int? ID {
                    get { return mID ; }
                    set { mID = value; }
    }

     About column visible order issue there're several posts  showing how to achieve a custom order.

Reply Children