We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Dynamically Highlight a specific row on a GridDataControl

Thread ID:

Created:

Updated:

Platform:

Replies:

119383 Jun 12,2015 11:56 AM Jun 16,2015 02:52 PM WPF 3
loading
Tags: GridDataControl
Ari Case
Asked On June 12, 2015 11:56 AM

When you click or select a record on a GridDataControl, that row becomes the active row and is highlighted.

I'm trying to utilize the event that highlights a row on the GridDataControl after selecting.

I ultimately want to dynamically choose which row I want highlighted based on a specific value, but I'm not sure what event does this.

Any help is appreciated, thanks!

Ashok N [Syncfusion]
Replied On June 15, 2015 08:58 AM

Hi Ari,

Thank you for contacting Syncfusion support.

We have analyzed your query and you can achieve your requirement by handling QueryCellInfo event, within this event you can set the Background for selected row by using GridDataControl.Model.Options.HighlightSelectionBackground property. For your refer we have attached the sample in the below sample link, please refer it.

public MainWindow()

{

    InitializeComponent();

    grid.Loaded += grid_Loaded;

}


void grid_Loaded(object sender, RoutedEventArgs e)

{

    this.grid.Model.QueryCellInfo += Model_QueryCellInfo;

}


void Model_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e)

{

    if (e.Style.RowIndex > 0)

    {

        var column = this.grid.VisibleColumns["EmployeeID"];

        int index = this.grid.VisibleColumns.IndexOf(column);

        var visiablecolumnindex= this.grid.Model.ResolveVisibleColumnIndexToPosition(index);

        var cell = this.grid.Model[e.Style.RowIndex, visiablecolumnindex].CellValue;

        var result = Convert.ToInt32(cell);

        if (result % 3 == 0)

        {

            this.grid.Model.Options.HighlightSelectionBackground = Brushes.Green;

        }

        else

            e.Style.Enabled = false;

    }

}

Sample link: http://www.syncfusion.com/downloads/support/forum/119383/ze/BackgroundColor1819005304

Please let us know if you require further assistance on this.

Thanks,

Ashok


Ari Case
Replied On June 15, 2015 12:35 PM

This helps but I'm trying to programmatically check for a specific value in a cell.

For example, as I loop through the grid, if column 3 equals "Hello" at row index 4, highlight that whole row.

Ashok N [Syncfusion]
Replied On June 16, 2015 02:52 PM

Hi Ari,

Thank you for update.

We have analyzed your query but we are unable to understand your requirement clearly. In our previous update itself we have highlight the whole row based on the cell value only. Could you please share more details regarding your requirement, that would be more helpful for further analyze.

Please let us know if you require further assistance.

Thanks,
Ashok



CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;