Custom datagrid column

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • VC

    Custom datagrid column

    Hi, could someone points me to a article, whitepaper or other about
    how to create a simple custimized column for a (2008 .net)
    DataGridView windows form control?

    I've saw a lot of sample over the internet but all of them too much
    complicated. I just need something simple since I'm a begginer in C#.

    Thanks in advance.
  • =?Utf-8?B?anAybXNmdA==?=

    #2
    RE: Custom datagrid column

    Not sure where an example would be online, but here's a technique that I use:

    Create a DataTable with the columns you are interested in. Fill all of your
    rows using the logic you created the columns with, then add the DataTable to
    your DataGridView control.

    EXAMPLE:
    // Start Example Code:
    DataTable table = new DataTable();
    DataColumn col1 = table.Columns.A dd("Col 1 Int32",
    Type.GetType("S ystem.Int32"));
    DataColumn col2 = table.Columns.A dd("Col 2 String",
    Type.GetType("S ystem.String")) ;
    for (int i = 0; i < 5; i++) {
    DataRow r = table.NewRow();
    r[col1] = i;
    r[col2] = string.Format(" Data for {0}", i");
    table.Rows.Add( r);
    }
    DataGridView1.D ataSource = table.DefaultVi ew;
    // End of Example

    If this isn't what you need, could you be a little more specific in your
    question?

    "VC" wrote:
    Hi, could someone points me to a article, whitepaper or other about
    how to create a simple custimized column for a (2008 .net)
    DataGridView windows form control?
    >
    I've saw a lot of sample over the internet but all of them too much
    complicated. I just need something simple since I'm a begginer in C#.
    >
    Thanks in advance.
    >

    Comment

    • VC

      #3
      Re: Custom datagrid column

      Hi

      I 'd like to know how to create customized coluns on a DataGRidView.
      In the past on VS2003, we were able to create coluns like
      DataboundColunm , CheckBoxcolumn and so on. How do I create this kind
      of columns in VC2008 datagridview now?

      Or the unique way is creating customized columns on datatable and them
      perform a dotabound?


      On 7 nov, 20:26, jp2msft <jp2m...@discus sions.microsoft .comwrote:
      Not sure where an example would be online, but here's a technique that I use:
      >
      Create a DataTable with the columns you are interested in. Fill all of your
      rows using the logic you created the columns with, then add the DataTableto
      your DataGridView control.
      >
      EXAMPLE:
      // Start Example Code:
      DataTable table = new DataTable();
      DataColumn col1 = table.Columns.A dd("Col 1 Int32",
      Type.GetType("S ystem.Int32"));
      DataColumn col2 = table.Columns.A dd("Col 2 String",
      Type.GetType("S ystem.String")) ;
      for (int i = 0; i < 5; i++) {
        DataRow r = table.NewRow();
        r[col1] = i;
        r[col2] = string.Format(" Data for {0}", i");
        table.Rows.Add( r);}
      >
      DataGridView1.D ataSource = table.DefaultVi ew;
      // End of Example
      >
      If this isn't what you need, could you be a little more specific in your
      question?
      >
      "VC" wrote:
      Hi, could someone points me to a article, whitepaper or other about
      how to create a simple custimized column for a (2008 .net)
      DataGridView windows form control?
      >
      I've saw a lot of sample over the internet but all of them too much
      complicated. I just need something simple since I'm a begginer in C#.
      >
      Thanks in advance.

      Comment

      • =?Utf-8?B?anAybXNmdA==?=

        #4
        Re: Custom datagrid column

        Could you post some example code of what you did and how you did it in VS2003?

        If a DataColumn is specified as a Bit field (Boolean), CheckBoxes should
        still show up whenever you include the DataTable containing the DataColumn to
        your DataGridView.

        "VC" wrote:
        Hi
        >
        I 'd like to know how to create customized coluns on a DataGRidView.
        In the past on VS2003, we were able to create coluns like
        DataboundColunm , CheckBoxcolumn and so on. How do I create this kind
        of columns in VC2008 datagridview now?
        >
        Or the unique way is creating customized columns on datatable and them
        perform a dotabound?
        >
        >
        On 7 nov, 20:26, jp2msft <jp2m...@discus sions.microsoft .comwrote:
        Not sure where an example would be online, but here's a technique that I use:

        Create a DataTable with the columns you are interested in. Fill all of your
        rows using the logic you created the columns with, then add the DataTable to
        your DataGridView control.

        EXAMPLE:
        // Start Example Code:
        DataTable table = new DataTable();
        DataColumn col1 = table.Columns.A dd("Col 1 Int32",
        Type.GetType("S ystem.Int32"));
        DataColumn col2 = table.Columns.A dd("Col 2 String",
        Type.GetType("S ystem.String")) ;
        for (int i = 0; i < 5; i++) {
        DataRow r = table.NewRow();
        r[col1] = i;
        r[col2] = string.Format(" Data for {0}", i");
        table.Rows.Add( r);}

        DataGridView1.D ataSource = table.DefaultVi ew;
        // End of Example

        If this isn't what you need, could you be a little more specific in your
        question?

        "VC" wrote:
        Hi, could someone points me to a article, whitepaper or other about
        how to create a simple custimized column for a (2008 .net)
        DataGridView windows form control?
        I've saw a lot of sample over the internet but all of them too much
        complicated. I just need something simple since I'm a begginer in C#.
        Thanks in advance.
        >
        >

        Comment

        Working...