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
1140
Override AppStylist ActiveRow Settings
posted

I am attempting to override the appStylist theme setting for the Active UltraGridRow.  Even if I False UseOSThemes, and False UseAppStyling I can not override the Active UltraGridRow Appearance.  The purpouse is to provide a visual to the user that will indicate when an object is selected or not.  This functionality works fine once the AfterSelectChange event is fired, i.e. activate a new row.  I need to change the appearance of the active row itself.  For instance if I click once on a row it should activate with the themed appearance.  If I click on that row once more it should change the apperance of the active row.

Here's a simple example of one way I have tried.

 

Row.Appearance.BackColor = Color.White;

Row.Appearance.BackGradientStyle = GradientStyle.GlassBottom37Bright;

Row.Appearance.BackColor2 = Color.Green;

Row.Appearance.BackColorAlpha = Alpha.Opaque;

Row.Appearance.ForeColor = Color.Black;

 

Parents
No Data
Reply
  • 1140
    posted

    Figured out a pretty easy way of doing this, just had to find the appropriate namespace I guess.  Any way here is a brief example of toggeling the active row appearance based on cell value.

     First set the grid property UseOsThemes to False.

     Second set the UseAppStyling Property to False.

     Third Create the property below.

    /// <summary>

    /// Sets the active row and selected row appearances based on the field "Boolean" value

    /// </summary>private bool ModifyRowSettings

    {

    set

    {

    if (value == true)

    {

    Grid.ActiveRow.Cells[
    "String"].Value = "False";

    Grid.ActiveRow.Band.Override.ActiveRowAppearance.BackColor = Color.White;

    Grid.ActiveRow.Band.Override.ActiveRowAppearance.BackColor2 = Color.WhiteSmoke;

    Grid.ActiveRow.Band.Override.ActiveRowAppearance.ForeColor = Color.Black;

    Grid.ActiveRow.Appearance.BackColor = Color.White;

    Grid.ActiveRow.Appearance.BackColor2 = Color.WhiteSmoke;

    Grid.ActiveRow.Appearance.ForeColor = Color.Black;

    }

    else if (value == false)

    {

    Grid.ActiveRow.Cells[
    "String"].Value = "True";

    Grid.ActiveRow.Band.Override.ActiveRowAppearance.BackColor = Color.Orange;

    Grid.ActiveRow.Band.Override.ActiveRowAppearance.BackColor2 = Color.Wheat;

    Grid.ActiveRow.Band.Override.ActiveRowAppearance.ForeColor = Color.WhiteSmoke;

    Grid.ActiveRow.Band.Override.ActiveRowAppearance.BackGradientStyle = GradientStyle.GlassTop37;

    Grid.ActiveRow.Appearance.BackColor = Color.Orange;

    Grid.ActiveRow.Appearance.BackColor2 = Color.Wheat;

    Grid.ActiveRow.Appearance.ForeColor = Color.WhiteSmoke;

    Grid.ActiveRow.Appearance.BackGradientStyle = GradientStyle.GlassTop37;

    }

    }

    }

     

    Fourth:  Not sure if you'll need this functionality, but I call this method via the mouse down event.  Here is how I am accomplishing it, who knows it may or may not help you.

    private void Grid_MouseDown(object sender, MouseEventArgs e)

    {

    if (this.Grid.ActiveRow == null) { return; }

    Point pt = new Point(e.X, e.Y);

    if (this.Grid.DisplayLayout.ActiveRow.GetUIElement().PointInElement(pt))

    {

    //Single select only clear all other rows.

    for (int i = 0; i <= this.Grid.Rows.Count - 1; i++)

    {

    if (this.Grid.RowsIdea.HasCell("Boolean"))

    {

    if (this.Grid.RowsIdea != this.Grid.ActiveRow)

    {

    this.Grid.RowsIdea.Cells["Boolean"].Value = "False";this.Grid.RowsIdea.Appearance.Reset();

    }

    }

    }

    //set the appearance of the row

    this.ModifyRowSettings = Convert.ToBoolean(this.Grid.ActiveRow.Cells["Boolean"].Value);

    }

    }

    Im sure there is a much much easier way of achieving this, I attempted to use the grid formulas and value based cell appearance to accomplish this but I am still learning the ins and outs of the infragistics controls.  If your grid supports multiple selection and you want to simulate the ctrl + click functionality with out the end user actually having to hold down the control key, just remove the for statment in the mouse down event.

     

    Hope this helps someone :)

Children