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
420
Error when conditional formatting is present and you try to load a layout from XML.
posted

Hi..

This error happens when we have a conditional formatting code and then you try to load a new layout. The error is "Exception thrown by the target of invocation". The workaround is to use the initialize grid row event instead of conditional formatting. Any ideas?

InitializeLayout event code: (Red color for numbers less than 0)

OperatorCondition conditionLessThen0 = new OperatorCondition(ConditionOperator.LessThan, 0);

Infragistics.Win.Appearance appearanceRed = new Infragistics.Win.Appearance();

appearanceRed.ForeColor = Color.Red;ConditionValueAppearance valAppearanceLessThen0 = new ConditionValueAppearance();

valAppearanceLessThen0.Add(conditionLessThen0, appearanceRed);

column.ValueBasedAppearance = valAppearanceLessThen0;

 

Load layout code on click of a button:

if (File.Exists(LayoutFilenameTrades))

grdPnLGrid.DisplayLayout.LoadFromXml(LayoutFilenameTrades);

Parents
  • 20
    posted

    I'm having the exact same issue here using v8.1 of the WinGrid. Basically, display layouts cannot be loaded to the grid when I use conditional formatting on the columns. I get the "Exception has been thrown by the target of an invocation." exception.

    Sample code (with oColumn being a column in the grid and ultraGrid1 being my grid):

    ConditionValueAppearanceForm conditionValueAppearanceForm = new ConditionValueAppearanceForm( oColumn );
    DialogResult result = conditionValueAppearanceForm.ShowDialog( this );
    if ( result == DialogResult.OK )
    {
        // If the user clicked OK, set the ConditionValueAppearance on the column.
        oColumn.ValueBasedAppearance = conditionValueAppearanceForm.ConditionValueAppearance;
        ultraGrid1.DisplayLayout.SaveAsXml( "layout.xml" );
        ultraGrid1.DisplayLayout.LoadFromXml( "layout.xml" ); // This throws the exception
    }

    If anyone has any ideas here, it would be greatly appreciated. I created an incident report already. I'm expecting my users to create their own simple or complex profiles, so I need the intended behavior. I have it so that a user could filter Column A and then set up formatting so that when Column B has a value greater than 0, Column A would show up with a background color of red. I can save that layout fine. But, I need the grid to have that view the next time he/she opens the application, and that's where the exception occurs every time. The exception goes away if I remove the conditional formatting from the column.
     

Reply Children