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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

GridConditionalFormatDescriptor. Appearance Property''s Precedence

Thread ID:

Created:

Updated:

Platform:

Replies:

21848 Nov 24,2004 04:19 PM UTC Nov 24,2004 05:39 PM UTC WinForms 1
loading
Tags: Grouping
Erlly Bayuelo
Asked On November 24, 2004 04:19 PM UTC

Hi, I am trying to set rows that have a certain field''s value < 0 to a certain BackColor using the GridConditionalFormatDescriptor. For Example: gridConditionalFormatDescriptorShortPos.Appearance.AnyCell.BackColor = Color.Salmon; However when I initially format my grid I am setting the color of all the grid columns conditionally (depending of whether the column is readonly or editable, etc..) using: col.Appearance.AnyCell.BackColor where col is a GridColumnDescriptor. I am noticing that no matter if I create my ConditionalFormatter before or after I set all the GridColumnDescriptor''s color the formatter has no effect. However if I comment out the code that sets my ColumnDescriptors colors then the conditional formatting works just fine for the wanted rows. Which takes precedence the conditional formatting using GridConditionalFormatDescriptor or the appearance of the GridColumnDescriptors?

Administrator [Syncfusion]
Replied On November 24, 2004 05:39 PM UTC

Hi Erly, quick tip: If you handle QueryCellStyleInfo event as follows as Tooltip will show up that tells you where the cell gets its Appearance from: private void groupingGrid1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e) { e.Style.CellTipText = e.TableCellIdentity.Info; } Regarding your initial question: The appearance of the column descriptor has predence over conditional format. If you want to give the row higher precedence, you could try that with a base styles: Assign a base style to the column descriptor and assign style properties directly to the conditional format. Below is code for a modified InitializeComponent method for the "CategoryView" example. Replace it in the form1.cs code. All cells in conditial row will be orrange and override the columns color. #region Windows Form Designer generated code /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { Syncfusion.Windows.Forms.Grid.Grouping.GridTableBaseStyle gridTableBaseStyle1 = new Syncfusion.Windows.Forms.Grid.Grouping.GridTableBaseStyle("Orange"); Syncfusion.Windows.Forms.Grid.Grouping.GridTableBaseStyle gridTableBaseStyle2 = new Syncfusion.Windows.Forms.Grid.Grouping.GridTableBaseStyle("Beige"); Syncfusion.Windows.Forms.Grid.Grouping.GridTableBaseStyle gridTableBaseStyle3 = new Syncfusion.Windows.Forms.Grid.Grouping.GridTableBaseStyle("LightBlue"); Syncfusion.Windows.Forms.Grid.Grouping.GridColumnDescriptor gridColumnDescriptor1 = new Syncfusion.Windows.Forms.Grid.Grouping.GridColumnDescriptor(); Syncfusion.Windows.Forms.Grid.Grouping.GridConditionalFormatDescriptor gridConditionalFormatDescriptor1 = new Syncfusion.Windows.Forms.Grid.Grouping.GridConditionalFormatDescriptor(); this.gridGroupingControl1 = new Syncfusion.Windows.Forms.Grid.Grouping.GridGroupingControl(); this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand(); this.sqlConnection1 = new System.Data.SqlClient.SqlConnection(); this.sqlInsertCommand1 = new System.Data.SqlClient.SqlCommand(); this.sqlUpdateCommand1 = new System.Data.SqlClient.SqlCommand(); this.sqlDeleteCommand1 = new System.Data.SqlClient.SqlCommand(); this.sqlDataAdapter1 = new System.Data.SqlClient.SqlDataAdapter(); this.btnSaveXmlSchema = new System.Windows.Forms.Button(); this.btnLoadXmlSchema = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.gridGroupingControl1)).BeginInit(); this.SuspendLayout(); // // gridGroupingControl1 // this.gridGroupingControl1.Anchor = (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right); this.gridGroupingControl1.Appearance.AnyCell.AutoSize = true; this.gridGroupingControl1.Appearance.AnyCell.BaseStyle = "LightBlue"; this.gridGroupingControl1.BackColor = System.Drawing.SystemColors.Window; gridTableBaseStyle1.Name = "Orange"; gridTableBaseStyle1.StyleInfo.BaseStyle = ""; gridTableBaseStyle1.StyleInfo.Interior = new Syncfusion.Drawing.BrushInfo(System.Drawing.Color.FromArgb(((System.Byte)(238)), ((System.Byte)(122)), ((System.Byte)(3)))); gridTableBaseStyle2.Name = "Beige"; gridTableBaseStyle2.StyleInfo.BaseStyle = "BaseStyle 1"; gridTableBaseStyle2.StyleInfo.CellAppearance = Syncfusion.Windows.Forms.Grid.GridCellAppearance.Sunken; gridTableBaseStyle2.StyleInfo.Interior = new Syncfusion.Drawing.BrushInfo(System.Drawing.Color.FromArgb(((System.Byte)(255)), ((System.Byte)(191)), ((System.Byte)(52)))); gridTableBaseStyle3.Name = "LightBlue"; gridTableBaseStyle3.StyleInfo.BaseStyle = ""; gridTableBaseStyle3.StyleInfo.Interior = new Syncfusion.Drawing.BrushInfo(System.Drawing.Color.FromArgb(((System.Byte)(219)), ((System.Byte)(226)), ((System.Byte)(242)))); this.gridGroupingControl1.BaseStyles.AddRange(new Syncfusion.Windows.Forms.Grid.Grouping.GridTableBaseStyle[] { gridTableBaseStyle1, gridTableBaseStyle2, gridTableBaseStyle3}); this.gridGroupingControl1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.gridGroupingControl1.Location = new System.Drawing.Point(32, 16); this.gridGroupingControl1.Name = "gridGroupingControl1"; this.gridGroupingControl1.Size = new System.Drawing.Size(560, 320); this.gridGroupingControl1.TabIndex = 0; gridColumnDescriptor1.Appearance.AnyRecordFieldCell.BaseStyle = "Orange"; gridColumnDescriptor1.MappingName = "CategoryID"; this.gridGroupingControl1.TableDescriptor.Columns.AddRange(new Syncfusion.Windows.Forms.Grid.Grouping.GridColumnDescriptor[] { gridColumnDescriptor1, new Syncfusion.Windows.Forms.Grid.Grouping.GridColumnDescriptor("CategoryName"), new Syncfusion.Windows.Forms.Grid.Grouping.GridColumnDescriptor("Description"), new Syncfusion.Windows.Forms.Grid.Grouping.GridColumnDescriptor("Picture")}); gridConditionalFormatDescriptor1.Appearance.AnyRecordFieldCell.Interior = new Syncfusion.Drawing.BrushInfo(System.Drawing.Color.Red); gridConditionalFormatDescriptor1.Expression = "[CategoryID]=1"; gridConditionalFormatDescriptor1.Name = "ConditionalFormat 1"; this.gridGroupingControl1.TableDescriptor.ConditionalFormats.Add(gridConditionalFormatDescriptor1); this.gridGroupingControl1.TableOptions.RecordRowHeight = 57; this.gridGroupingControl1.Text = "gridGroupingControl1"; // // sqlSelectCommand1 // this.sqlSelectCommand1.CommandText = "SELECT CategoryID, CategoryName, Description, Picture FROM Categories"; this.sqlSelectCommand1.Connection = this.sqlConnection1; // // sqlConnection1 // this.sqlConnection1.ConnectionString = "data source=(local)\\NETSDK;initial catalog=Northwind;integrated security=SSPI;per" + "sist security info=True;workstation id=localhost;packet size=4096"; // // sqlInsertCommand1 // this.sqlInsertCommand1.CommandText = "INSERT INTO Categories(CategoryName, Description, Picture) VALUES (@CategoryName," + " @Description, @Picture); SELECT CategoryID, CategoryName, Description, Picture " + "FROM Categories WHERE (CategoryID = @@IDENTITY)"; this.sqlInsertCommand1.Connection = this.sqlConnection1; this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@CategoryName", System.Data.SqlDbType.NVarChar, 15, "CategoryName")); this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Description", System.Data.SqlDbType.NVarChar, 1073741823, "Description")); this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Picture", System.Data.SqlDbType.VarBinary, 2147483647, "Picture")); // // sqlUpdateCommand1 // this.sqlUpdateCommand1.CommandText = @"UPDATE Categories SET CategoryName = @CategoryName, Description = @Description, Picture = @Picture WHERE (CategoryID = @Original_CategoryID) AND (CategoryName = @Original_CategoryName); SELECT CategoryID, CategoryName, Description, Picture FROM Categories WHERE (CategoryID = @CategoryID)"; this.sqlUpdateCommand1.Connection = this.sqlConnection1; this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@CategoryName", System.Data.SqlDbType.NVarChar, 15, "CategoryName")); this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Description", System.Data.SqlDbType.NVarChar, 1073741823, "Description")); this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Picture", System.Data.SqlDbType.VarBinary, 2147483647, "Picture")); this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_CategoryID", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "CategoryID", System.Data.DataRowVersion.Original, null)); this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_CategoryName", System.Data.SqlDbType.NVarChar, 15, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "CategoryName", System.Data.DataRowVersion.Original, null)); this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@CategoryID", System.Data.SqlDbType.Int, 4, "CategoryID")); // // sqlDeleteCommand1 // this.sqlDeleteCommand1.CommandText = "DELETE FROM Categories WHERE (CategoryID = @Original_CategoryID) AND (CategoryNam" + "e = @Original_CategoryName)"; this.sqlDeleteCommand1.Connection = this.sqlConnection1; this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_CategoryID", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "CategoryID", System.Data.DataRowVersion.Original, null)); this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_CategoryName", System.Data.SqlDbType.NVarChar, 15, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "CategoryName", System.Data.DataRowVersion.Original, null)); // // sqlDataAdapter1 // this.sqlDataAdapter1.DeleteCommand = this.sqlDeleteCommand1; this.sqlDataAdapter1.InsertCommand = this.sqlInsertCommand1; this.sqlDataAdapter1.SelectCommand = this.sqlSelectCommand1; this.sqlDataAdapter1.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] { new System.Data.Common.DataTableMapping("Table", "Categories", new System.Data.Common.DataColumnMapping[] { new System.Data.Common.DataColumnMapping("CategoryID", "CategoryID"), new System.Data.Common.DataColumnMapping("CategoryName", "CategoryName"), new System.Data.Common.DataColumnMapping("Description", "Description"), new System.Data.Common.DataColumnMapping("Picture", "Picture")})}); this.sqlDataAdapter1.UpdateCommand = this.sqlUpdateCommand1; // // btnSaveXmlSchema // this.btnSaveXmlSchema.Anchor = ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right); this.btnSaveXmlSchema.Location = new System.Drawing.Point(96, 360); this.btnSaveXmlSchema.Name = "btnSaveXmlSchema"; this.btnSaveXmlSchema.Size = new System.Drawing.Size(168, 24); this.btnSaveXmlSchema.TabIndex = 1; this.btnSaveXmlSchema.Text = "Save Xml Schema"; this.btnSaveXmlSchema.Click += new System.EventHandler(this.btnSaveXmlSchema_Click); // // btnLoadXmlSchema // this.btnLoadXmlSchema.Anchor = ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right); this.btnLoadXmlSchema.Location = new System.Drawing.Point(360, 360); this.btnLoadXmlSchema.Name = "btnLoadXmlSchema"; this.btnLoadXmlSchema.Size = new System.Drawing.Size(168, 24); this.btnLoadXmlSchema.TabIndex = 2; this.btnLoadXmlSchema.Text = "Load Xml Schema"; this.btnLoadXmlSchema.Click += new System.EventHandler(this.btnLoadXmlSchema_Click); // // Form1 // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(616, 414); this.Controls.AddRange(new System.Windows.Forms.Control[] { this.btnLoadXmlSchema, this.btnSaveXmlSchema, this.gridGroupingControl1}); this.Name = "Form1"; this.Text = "Form1"; ((System.ComponentModel.ISupportInitialize)(this.gridGroupingControl1)).EndInit(); this.ResumeLayout(false); } #endregion Stefan

CONFIRMATION

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

or the page will be automatically redirected to 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

;