Results 1 to 4 of 4

Thread: [RESOLVED] How do I Auto Number a Datagrid Column

  1. #1

    Thread Starter
    Member
    Join Date
    May 2005
    Posts
    49

    Resolved [RESOLVED] How do I Auto Number a Datagrid Column

    I have a data table which populates a datagrid on my form.
    I want to add a column whcih will number the records automatically.
    The user queries a database to get the number of records to be displayed in the datagrid through a stored procedure.

    Any help please?

    John

  2. #2
    Frenzied Member Zakary's Avatar
    Join Date
    Mar 2005
    Location
    Canada, Quebec, Montreal
    Posts
    1,654

    Re: How do I Auto Number a Datagrid Column

    Hi jbanafful!
    A way in witch you may do it, is by adding a unbound column in the DataGrid or add a dumy column in the binded DataTable.

    Then Create your own DataGridTextBoxColumn, attach to this "dumy" column , and overrides the Paint event, in this event you may display the Rows Index value or whatever you wish

    For more detail on How do I add an unbound column to a bound datagrid look here

    And for more detail about creating your own Column derived from DataGridTextBoxColumn look here
    Using VS 2010 on Fw4.0

  3. #3
    Addicted Member
    Join Date
    May 2005
    Posts
    162

    Re: How do I Auto Number a Datagrid Column

    it looks like this:
    VB Code:
    1. DataGrid.DataSource = ds.Tables(0).Columns.Add("something")
    if that helped me me out with this. how do i edit my datagrid?

  4. #4

    Thread Starter
    Member
    Join Date
    May 2005
    Posts
    49

    Re: How do I Auto Number a Datagrid Column

    I've solved it

    I use the IDENTITY Function in TSQL to Load the data into the table.
    It working well, thanks soo much

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width