Home Forums WinForms controls Xceed Grid for WinForms Changing cell backcolor based on data within

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

    With VS2005 datagridview, I could easily use the CellFormatting method to change the color of a cell based on the data using something like this:

    private void dgDatagrid_CellFormatting (object sender, DataGridViewCellFormattingEventArgs e)
    {
    if (dgDatagrid.Columns[e.ColumnIndex].Name.Equals(“pRiDataGridViewTextBoxColumn1”) && e.Value != null)
    if(e.Value.ToString() = “Med”)
    { e.CellStyle.BackColor = Color.Yellow; }
    }

    With the Xceed datagrid, I do not see any way to accomplish the same task. Any ideas?

    Imported from legacy forums. Posted by Randy (had 2480 views)

    User (Old forums)
    Member
    Post count: 23064

    I can’t believe no one has done something like this. This is my first post on this site while trying this software.

    Are there any people from XCeed who monitor and answer questions or is it just the users trying to help each other. I would of thought XCeed would of be trying to help users to sell their product like other 3rd party software companies and their forums.

    Imported from legacy forums. Posted by Randy (had 211 views)

    Xceed Support
    Member
    Post count: 5658

    Using the DeactivatingControl event on the CellEditorManager, you can reproduce easily the same effect (of a user entering a data and the cell format changing).

    <code>
    private void Form1_Load( object sender, EventArgs e )
    {
    //…

    foreach( Cell cell in dataRowTemplate1.Cells )
    {
    cell.CellEditorManager.DeactivatingControl += new CellEditorEventHandler( CellEditorManager_DeactivatingControl );
    }
    }

    void CellEditorManager_DeactivatingControl( object sender, CellEditorEventArgs e )
    {
    //…
    }
    </code>

    For the comments on the answers, if you scroll down and look at almost any other threads, you will likely see an answer from one of the Xceed employees.
    It’s also important that this forum is “community-supported”.

    Imported from legacy forums. Posted by CharlesB (had 3465 views)

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