Add button control inside DataGridView

1) I would like to show my table in the DataGridView and allow the user to edit some of the fields which are integer type. I need to put two buttons next to the value. One of them is to add 1 to the value while the other one will minus 1. It's idea to put the add button on top of the minus one. However, I can't find any good reference on how to do this. Please advise.

2) Moreover, how can I control the button behaviour I've tried adding the DataGridViewButtonColumn into my DataGridView. However, I've no way to program like the other button control.




Answer this question

Add button control inside DataGridView

  • Jordi

    You could try using the NumericUpDown control. It has exactly the same functionality you are looking for.
  • StimpE

    Yes. The solution is already available in MSDN. However, I've already abandoned this idea as this solution is not available at my time of writing.

  • dNetGuru

    Would it be possible to subclass DataGridViewCell to create your own cell and then subclass DataGridViewColumn to create the column to put it in


  • cbhkenshin

    2) For the second question, I've found that there's an event called "CellContentClick". Is it the proper way to check for the action I need to check the ColumnIndex from the System.Windows.Forms.DataGridViewCellEventArgs to know which button that I've clicked.

    3) Moreover, is it possible to hide the button once it's been clicked



  • Prabhu Sadasivam

    Please follow the link in the previous message. It seems that Microsoft is not supporting this.

  • SoCalChristopher

    I'm trying to achieve the same thing and i'm well on my way.

    The basics are described in this artikel


  • IanWho

    How can I use it in the DataGridView I think it's not so easy to achieve. Or maybe even impossible right now.

    http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=80483&SiteID=1



  • Add button control inside DataGridView