Lets color all rows that contain specific Company_Name value.
First of all we need to add DataBindingComplete event handler to the PivotalSearchResultsGrid control.
To do it we need to override OnFormInitialized method that fires after the form has been drawn and all the data has been loaded and bound:
public override void OnFormInitialized() { PivotalSearchResultsGrid mySearchResultsGrid = this.FormControl.GetControlByName("CompaniesPivotalSearchResultsGrid") as PivotalSearchResultsGrid; if (mySearchResultsGrid != null) { //Get a grid control from the PivotalSearchResultsGrid DataGridView grid = mySearchResultsGrid.ResultsViewControl.Controls[0].Controls[0] as DataGridView; //Handle DataBindingComplete event that fires when the content DataSource changed grid.d.DataBindingComplete += new DataGridViewBindingCompleteEventHandler(dataGridView1_DataBindingComplete); } }
Than just implement the dataGridView1_DataBindingComplete event handler:
private void dataGridView1_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e) { DataGridView grid = sender as DataGridView; for (int i = 0; i < grid.Rows.Count; i++ ) { DataGridViewRow row = grid.Rows[i]; //Access to row data string companyName = row.Cells["Company_Name"].Value.ToString(); if (companyName == "Microsoft") { //Paint row in Blue row.DefaultCellStyle.BackColor = Color.Blue; } } }
Thats all.
Enjoy with Pivotal 6.0.