Subclassing a DataGrid control

Discussion in 'ASP .Net Datagrid Control' started by Jeronimo Bertran, May 3, 2005.

  1. Hi,

    What is the correct way to sbuclass a datagrid that we want to use in the
    designer that includes default columns?

    I am trying to create a control that inherits from DataGrid and performs
    some standard manipulation (such as creating default columns)....



    public class MyGrid : System.Windows.Forms.DataGrid



    I add columns either with the designer or on the constructor:


    //
    // dataGridTableStyle
    //
    this.dataGridTableStyle.DataGrid = this;
    this.dataGridTableStyle.GridColumnStyles.AddRange(new
    System.Windows.Forms.DataGridColumnStyle[] {this.dataGridNameColumn});
    this.dataGridTableStyle.MappingName = "ArrayList";
    //
    // dataGridNameColumn
    //
    this.dataGridNameColumn.HeaderText = "Name";
    this.dataGridNameColumn.MappingName = "Name";


    Now, if I add my grid to the ToolBox and add it to a form, a new instance
    of the GridTableSytle and and GridColumnStyle is created in the form. I
    get an error because I now have 2 TableStyles with the same MappingName.
    If I delete the TableStyle collection from the designer then it then works
    ok and only the instance created on the class is used.

    Thanks,

    Jeronimo Bertran
    Jeronimo Bertran, May 3, 2005
    #1
    1. Advertising

  2. Hi Jeronimo,

    Welcome to ASPNET newsgroup.
    Regarding on the problem you mentioned, it seems related to winform
    control's Design-time developing. Based on my understanding , ASP.NET's
    datagrid control is much different from the winform datagrid, they have
    different underlying mechanism and design-time support. So if convenient ,I
    suggest you repost the quesiton in

    public.dotnet.framework.windowsforms newsgroup or its sub groups.

    Thanks,

    Steven Cheng
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)
    Steven Cheng[MSFT], May 4, 2005
    #2
    1. Advertising

  3. Yes, it has to do with the WinForms control... I didn't notice the aspnet
    part on the newsgroup name.

    Thanks,
    Jeronimo Bertran, May 9, 2005
    #3
  4. Nevermind Jeronimo,

    If you have any question on webform developing, please feel free to post in
    ASPNET group. We'll be glad to
    assist you. :--)

    Thanks,

    Steven Cheng
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)
    Steven Cheng[MSFT], May 10, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. S Guiboud
    Replies:
    1
    Views:
    401
    Ross Dempster
    Jul 18, 2003
  2. Charlie@CBFC
    Replies:
    1
    Views:
    524
    William F. Robertson, Jr.
    Apr 26, 2005
  3. Chris Cioffi
    Replies:
    13
    Views:
    487
    Christopher T King
    Jul 20, 2004
  4. David Rainsford

    Subclassing DataGrid

    David Rainsford, Apr 1, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    100
    Alvin Bruney [MVP]
    Apr 1, 2004
  5. Dan

    Subclassing DataGrid

    Dan, Feb 28, 2004, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    101
Loading...

Share This Page