Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
705
how to dynamically alter some row settings
posted

I have a C# app using the Infragistics ultragrid in a Winforms solution.  I need to do the following and I am unsure how after trolling through these forums.

1) currently when the grid is show on my form (using data binding) there is a row highlighted.  I would like to have nothing at all highlighted in the grid (or active) when the user first comes to it

2) I need to check the value in a column on a per row basis (before displaying the grid to the user).  If that row contains a certain value, then I need to change the background color for that whole row.

2) I need to check the value in a column on a per row basis.  If that row contains a certain value, then I need to effectively disable this row.  I am not allowing user edits on any of the data so editing is not a concern.  I don't want them to be able to select this row at all.  So if they try it simply ignores them (maybe supply a messagebox or something at the time too).

Is there an easy way to do this?  I am spinning my wheels here.  Thanks!

Parents
No Data
Reply
  • 45049
    Verified Answer
    posted

    skinpounder said:
    1) currently when the grid is show on my form (using data binding) there is a row highlighted.  I would like to have nothing at all highlighted in the grid (or active) when the user first comes to it

    Mike comments on this behavior, and what can be done about it, in the following thread:
    http://forums.infragistics.com/forums/t/12900.aspx

    skinpounder said:
    2) I need to check the value in a column on a per row basis (before displaying the grid to the user).  If that row contains a certain value, then I need to change the background color for that whole row.

    2) I need to check the value in a column on a per row basis.  If that row contains a certain value, then I need to effectively disable this row.  I am not allowing user edits on any of the data so editing is not a concern.  I don't want them to be able to select this row at all.  So if they try it simply ignores them (maybe supply a messagebox or something at the time too).

    Both of these can be accomplished by using the InitializeRow event.  This event is raised when the rows are created through data binding, and whenever the underlying data for that row is updated.

    In this event, take a look at the value of a particular cell in the row, and change the row's color.  For instance, assuming the grid has a boolean "ShowAsRed" coulmn:

    if ((bool) e.Row.GetCellValue("ShowAsRed") == true)
        e.Row.Appearance.BackColor = Color.Red;
    else
        e.Row.Appearance.BackColor = Color.Empty; // Resets to the "default" color

    Likewise, take a look at a different cell, and disable or enable the row based on that value.  For instance, assuming the same grid has a boolean "Enabled" column:

    if ((bool) e.Row.GetCellValue("Enabled") == false)
        e.Row.Activation = Infragistics.Win.UltraWinGrid.Activation.AllowEdit;
    else
        e.Row.Activation = Infragistics.Win.UltraWinGrid.Activation.Disabled; // or use Activation.NoEdit or Activation.ActivateOnly if you don't want to use a "disabled" appearance

     

Children