change command button color

2 posts, 0 answers
  1. Jhjang
    Jhjang avatar
    2 posts
    Member since:
    Dec 2014

    Posted 19 Mar 2015 Link to this post

    Hi

    I changed command button color using GridViewCommandColumn

    The below code is added in CommandCellClick event handler

    cell.CommandButton.ButtonFillElement.BackColor = frmColor.Color;

    this code changed the color, but when I add a new row, the color move to new row.

    And the cell which I changed the color of return default color.

    Could you let me know how I can change command button color in cell?
  2. Ralitsa
    Admin
    Ralitsa avatar
    176 posts

    Posted 20 Mar 2015 Link to this post

    Hi Jaeyong,

    Thank you for contacting us. 

    The CommandCellClick event is fired when you click on the button. If you need to change the appearance of the buttons that appear in the cells of the GridViewCommandColumn, it is better to subscribe to the CellFormatting event and change the BackColor property to desire color. Please take a look at the following code snippet which demonstrates how to achieve it: 
    if (e.CellElement.ColumnInfo is GridViewCommandColumn)
    {
        GridCommandCellElement element = (GridCommandCellElement)e.CellElement;
        element.CommandButton.ButtonFillElement.BackColor = Color.GreenYellow;
        element.CommandButton.ButtonFillElement.GradientStyle = Telerik.WinControls.GradientStyles.Solid;
    }

    More information about changing appearance of the grid cells can be found at Formatting Cells article, section Example 3: Change the appearance of the buttons in GridViewCommandColumn. 

    In attachments you can find the sample demo. 

    If this is not what you want to achieve, I would kindly ask you to send me a more detailed explanation what is your case and the code snippet from handler of the CommandCellClick event. 

    Let me know if I can assist you further.

    Regards,
    Ralitsa
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top