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
410
Cell.Appearance.BackColor cannot be changed in EditMode(urgent~)
posted

What i want to do is like this: if there is error in the cell, then the cursor cannot leave the cell and the back color of the cell should be red.

But the line to change backcolor didn't take effect, do you know why??

 

 

 

private

 

void ultraGrid1_BeforeExitEditMode(object sender, BeforeExitEditModeEventArgs e)

{

    ......

 

 

     if (hasError)

     {

 

 

       this.ultraGrid1.ActiveCell.Appearance.BackColor = Color.Red;

       e.Cancel =

true;                              

     }

}

Parents
  • 4940
    Offline posted

    While their investigation is in progress, here's a method that should work fine. I tested it as far back as 2010 Volume 2.

     

    private void ultraGrid1_BeforeExitEditMode(object sender, Infragistics.Win.UltraWinGrid.BeforeExitEditModeEventArgs e)  
    {  
        bool hasError = true;  
        if (hasError)  
        {  
            this.ultraGrid1.DisplayLayout.Override.ActiveCellAppearance.BackColor = Color.Red;  
            e.Cancel = true;  
        }  
    	else
    	{
    		this.ultraGrid1.DisplayLayout.Override.ActiveCellAppearance.BackColor = Color.White;
    	}
    }
    

    Or if you need Mike's fix that includes a text box, here's the snippet for that.

     

    private void ultraGrid1_BeforeExitEditMode(object sender, Infragistics.Win.UltraWinGrid.BeforeExitEditModeEventArgs e)  
    {  
        bool hasError = true;  
        if (hasError)  
        {  
            this.ultraGrid1.DisplayLayout.Override.ActiveCellAppearance.BackColor = Color.Red;  
            if (this.ultraGrid1.Controls.Count > 0)  
            {  
                TextBox textBox = this.ultraGrid1.Controls[0] as TextBox;  
                if (textBox != null)  
                    textBox.BackColor = Color.Red;  
            }  
            e.Cancel = true;  
      
        }
    	else
    	{
    		this.ultraGrid1.DisplayLayout.Override.ActiveCellAppearance.BackColor = Color.White;
    	}
    }
    

     

Reply Children
No Data