Results 1 to 3 of 3

Thread: Add column with buttons to datagrid

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2004
    Posts
    43

    Cool Add column with buttons to datagrid

    Hi guys,

    I have a dataset DSExcel which contains a datatable with 6 columns. I also have a windows (not ASP) datagrid whose datasource is set to the dataset. The datagrid contains a tablestyle.

    What I want to do is to add a column (tthe seventh column) to the datagrid (and dataset) which contains a button in very row. I also must be able to detect if the button in the datagrid cell is clicked.

    Is there anybody who can help me with this. I searched the internet and found a lot of examples for an ASP-datagrid but none for a windows datagrid.

    A code example would be welcome.

    Thanks

  2. #2
    Addicted Member
    Join Date
    Apr 2002
    Location
    California
    Posts
    160
    Actually you dont need a button in every row, if you put a button on a form you can determine what row is selected from the button_click event.

    VB Code:
    1. intRowIndex = DataGrid1.CurrentCell.RowNumber
    2. msgbox(DataGrid1.Item(intRowIndex,intColumnIndex))

    This will display a msgbox with the selected rows cell text based on the column that you specify.
    Jason Moore

    Software Engineer, Database Architect, Web Designer

    (C#,VB/NET,ASP/NET,COLDFUSION,JAVASCRIPT,SQL)

    http://www.gatorstudios.com
    [email protected]

  3. #3

    Thread Starter
    Member
    Join Date
    Jan 2004
    Posts
    43
    thanks jwmoore,

    but the code you suggested just retrieves the index of the column and row of the clicked cell and it returns the value of that cell.

    The code doesn't work in a winforms datagrid because you can't detect a click in a datagrid (or am i wrong?).

    I still would like to create a column with buttons....

    Any ideas?

    Thanks,

    Tom

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