I\'m importing GridView
from excel
I need to show a message near every empty cell to give the user information about what it should be writing..
You can color the XtraGrid cells using Conditional Formatting feature:
gridControl1.DataSource = new List {
new Person(){ Name = "John", Age = 25 },
new Person(){ Name = "Mary", Age = 17 },
new Person(){ Age = 17 },
new Person(){ Name = "Ann" },
new Person(){ Name = "Pit", Age = 5 },
};
StyleFormatCondition nameCondition = new StyleFormatCondition();
nameCondition.Column = gridView1.Columns["Name"];
nameCondition.Condition = FormatConditionEnum.Expression;
nameCondition.Expression = "IsNullOrEmpty([Name])";
nameCondition.Appearance.BackColor = Color.Red;
nameCondition.Appearance.Options.UseBackColor = true;
StyleFormatCondition ageCondition = new StyleFormatCondition();
ageCondition.Column = gridView1.Columns["Age"];
ageCondition.Condition = FormatConditionEnum.Expression;
ageCondition.Expression = "[Age]<10";
ageCondition.Appearance.BackColor = Color.Maroon;
ageCondition.Appearance.Options.UseBackColor = true;
gridView1.FormatConditions.AddRange(new StyleFormatCondition[] {
nameCondition, ageCondition
});
Result:
Related Links:
Customizing Appearances of Individual Rows and Cells
Style Format Conditions
Custom Painting (Samples)