Articles in this section

how to change the button color in GridDataBoundGrid using QueryCellInfo event?

To change the style of a cell or specific cell type you need to use QueryCellInfo event. PrepareViewStyleInfo event can also be used instead of QueryCellInfo.

C#

//Event Handler
this.gridDataBoundGrid1.Model.QueryCellInfo += Model_QueryCellInfo;
void Model_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e)
        {
            if (e.ColIndex == 4 && e.RowIndex > 0)
            {
                e.Style.CellType = GridCellTypeName.PushButton;
                e.Style.HorizontalAlignment = GridHorizontalAlignment.Center;
                e.Style.VerticalAlignment = GridVerticalAlignment.Middle;
                e.Style.Description = "Test";
                e.Style.TextColor = Color.Red;
                e.Style.BackColor = Color.AliceBlue;            }        }

 

 VB

'Event Handler
 Me.gridDataBoundGrid1.Model.QueryCellInfo
 void Model_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e)
      {
            if (e.ColIndex == 4 && e.RowIndex > 0)
            {
                e.Style.CellType = GridCellTypeName.PushButton;
                e.Style.HorizontalAlignment = GridHorizontalAlignment.Center;
                e.Style.VerticalAlignment = GridVerticalAlignment.Middle;
                e.Style.Description = "Test";
                e.Style.TextColor = Color.Red;
                e.Style.BackColor = Color.AliceBlue;
            }
      }

 

Screenshot

Crid Data Bound Grid Screenshot

 

Sample Links

C#: ButtonColorChange_CS

VB: ButtonColorChange_VB

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Access denied
Access denied