Results 1 to 4 of 4

Thread: Add Button To DataGridView Cell

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2011
    Posts
    14

    Add Button To DataGridView Cell

    Hi,

    I have a one column DataGridView that I use to display data from a database.

    Is it possible add a command button to one of the cells in that column? I don't want a second column as a DataGridViewButtonColumn. I want the rows containing the database data and the command button row in the same column.

    Also, if that is possible, I don't want the button's width to be the same as the column's width. Is it possible to manually set the width property?

    Thanks for you help.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Add Button To DataGridView Cell

    There is no cell class that provides that functionality. If that's what you want then you're going to have to define your own custom cell class.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    New Member
    Join Date
    Mar 2011
    Posts
    14

    Re: Add Button To DataGridView Cell

    Thanks for your reply. Creating custom cells and column is something that certainly interests me, but unfortuately that is currently outside my skill level.

    To create a cell class that contains a command button, I presume it would interit the DataGridViewCell, but I don't know where to begin to add the command button.

    I don't want to take up too much of your time, but any instructions/sample code would be highly appreciated.

    Thanks.

  4. #4
    Master Of Orion ForumAccount's Avatar
    Join Date
    Jan 2009
    Location
    Canada
    Posts
    2,802

    Re: Add Button To DataGridView Cell

    In this example they create a custom DataGridViewCell that can host multiple RadioButtons.

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