Home Forums WinForms controls Xceed Grid for WinForms Button with image in grid

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #13706 |

    Hi all,

    I need to implement clickable images (probably buttons?) in the grid. The grid contains around 20 lines and you could select 10 of them. By default none is select so the first column should contain a green checkmark. The user should click there to activate the line. If the user clicks on the checkmark, the icon should be replaced by a red X. If the user then presses the red X the line should be disabled again. What is the bast way to do this? I already searched the forum and found these articles
    <a href=”http://www.xceedsoft.com/Forums/ShowPost.aspx?PostID=2811″>Thread: Troubles Adding Buttons to a Grid</a>
    <a href=”http://www.xceedsoft.com/Forums/ShowPost.aspx?PostID=1346″>Thread: Adding buttons to Grid</a>
    Unfortunately I still did not get it to work 🙁 Main problem is the click event. I’m currently not sure how I could address the click action…..By the way, I’m using Grid 2.2 with VB.net but C# is also fine. Thanks a lot!!

    Imported from legacy forums. Posted by Kai (had 2648 views)

    User (Old forums)
    Member
    Post count: 23064

    You don’t necessarily need a button. What you could do is this:
    – create a class that implements the ICellViewer-interface and that paints a green checkmark if the value of the cell is 1 and a red X if the value of the cell is 0.
    – set the CellViewer-property of the column to an instance of this class.
    – catch the Click-event of the Cell on the DataRowTemplate, like this: grid.DataRowTemplate.Cells[“myCell”].Click += new EventHandler(cell_Click);
    – in the eventhandler, convert the sender-argument to a Cell, and change the value of the cell from 0 to 1 or from 1 to 0.

    To implement the ICellViewer-class, look in the Xceed documentation.

    Imported from legacy forums. Posted by Tommy (had 231 views)

    User (Old forums)
    Member
    Post count: 23064

    Hi Tommy,

    wow, this was both very fast and very helpful. Thanks a lot !!! 😀 I’ll try this but it sounds very good and also easy.

    Imported from legacy forums. Posted by Kai (had 3452 views)

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.