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. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Dynamically setting cell properties

Thread ID:





21273 Nov 5,2004 01:15 PM UTC Nov 5,2004 06:10 PM UTC WinForms 1
Tags: GridControl
Neal Tillotson
Asked On November 5, 2004 01:15 PM UTC

Hi, A few questions about conditionally setting cell properties: 1. In the below code sample, the readonly property is being properly set in the desired columns and rows. The backcolor property, however, is being improperly set to red in what appear to be random rows. After the initial load of the grid, clicking on random rows will produce random red cells (although all in the proper column). 2. Why would this exact same code produce no result in the PrepareViewStyleInfo event? 3. What''s the simplest way change the textcolor of a cell once it''s been edited? Please note that all columns are initialized to ReadOnly = true. private void gridLedger_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e) { if(data condition is met...) { this.gridLedger.Model.IgnoreReadOnly = true; e.Style.ReadOnly = false; e.Style.BackColor = System.Drawing.Color.Red; this.gridLedger.Model.IgnoreReadOnly = false; } } Regards, Neal

Administrator [Syncfusion]
Replied On November 5, 2004 06:10 PM UTC

Try not using IgnoreReadOnly to see if this will avoid the problem. It should not be needed in QueryCellInfo. Here is a KB on why ReadONly needs to be set in QueryCellInfo and not PrepareViewStyleInfo. http://www.syncfusion.com/Support/article.aspx?id=10351 To set the color while you are editing, try handling PrepareViewStyleInfo. If the e.ColIndex and e.RowIndex point to the current cell (grid.CurrentCell.RowIndex and grid.CurrentCell.COlIndex) and grid.CurrentCell.IsEditing, then set teh color.


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon 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.Close Icon

Live Chat Icon For mobile
Live Chat Icon