Home Forums WinForms controls Xceed Grid for WinForms Adding buttons to Grid

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

    Hi ,
    I have a requirement where i need to have a up /down button column in each row for the user to move the change the sequence of rows in the grid. For this i need to add a button with an image (arrows up & down). I had a look at the forum and managed to download a sample to implement button in a datarow. But its too much code to write. This is a very common requirement in a grid, i wonder why can’t Xceed have a button as a Grid Editor just like combo box and rest. Is there any update i am missing ??

    Cheers,

    Imported from legacy forums. Posted by Sharad (had 3041 views)

    User (Old forums)
    Member
    Post count: 23064

    Hello,

    Sorry I don’t have an answer to your problem other than the same sample you are working with. But I am having problems changing the sequence of the rows. Do you have example code for that?

    Reqards,

    Kevin

    Imported from legacy forums. Posted by dcpud (had 249 views)

    Odi [Xceed]
    Spectator
    Post count: 426

    Hi,

    I have an answer (below) to your request – but just so you know, we are planning to release a suite of editor controls that will all work with the grid, so this type of request will be even easier to solve.

    Meanwhile, here’s how to do it today. You can do something like this (with v2.1):

    // This will cause the editor to be activated on the first click.
    grid.SingleClickEdit = true;

    // Initialize a button to serve has editor and subscribe to the click event.
    Button button = new Button();
    button.Click += new EventHandler( button_Click );

    // Initialize the cell’s to an empty string (Only necessary if the cell is containing a Null value).
    foreach( Xceed.Grid.DataRow dataRow in grid.DataRows )
    dataRow.Cells[“Test1”].Value = string.Empty;

    // Set the editor and viwer on the column.
    grid.Columns[“Test1”].CellViewer = new ControlViewer( new Button(), “Text” );
    grid.Columns[“Test1”].CellEditor = new CustomEditor( button, “Text”, true );

    This will get you a button-like cell in a grid, and on the click you can do what you want.

    Hope this helps.

    Imported from legacy forums. Posted by Odi [Xceed] (had 3777 views)

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