I have the below code working, but there has GOT to be a better way...
Whenever a cell change event happens, check it if is one of our target cells, if so change the first character of the headertext:
private
void
radGridView1_CurrentCellChanged(
object
sender, CurrentCellChangedEventArgs e)
{
var test = e.NewCell;
if
(test.ColumnInfo.Name ==
"podName"
)
{
this
.radGridView1.Columns[
"podName"
].HeaderText =
"*Name"
;
this
.radGridView1.Columns[
"podTime"
].HeaderText =
"Time"
;
this
.radGridView1.Columns[
"podDate"
].HeaderText =
"Date"
;
this
.radGridView1.Columns[
"podQty"
].HeaderText =
"Qty"
;
}
else
{
this
.radGridView1.Columns[
"podName"
].HeaderText =
"Name"
;
}
if
(test.ColumnInfo.Name ==
"podTime"
)
{
this
.radGridView1.Columns[
"podName"
].HeaderText =
"Name"
;
this
.radGridView1.Columns[
"podTime"
].HeaderText =
"*Time"
;
this
.radGridView1.Columns[
"podDate"
].HeaderText =
"Date"
;
this
.radGridView1.Columns[
"podQty"
].HeaderText =
"Qty"
;
}
else
{
this
.radGridView1.Columns[
"podTime"
].HeaderText =
"Time"
;
}
if
(test.ColumnInfo.Name ==
"podDate"
)
{
this
.radGridView1.Columns[
"podName"
].HeaderText =
"Name"
;
this
.radGridView1.Columns[
"podTime"
].HeaderText =
"Time"
;
this
.radGridView1.Columns[
"podDate"
].HeaderText =
"*Date"
;
this
.radGridView1.Columns[
"podQty"
].HeaderText =
"Qty"
;
}
else
{
this
.radGridView1.Columns[
"podDate"
].HeaderText =
"Date"
;
}
if
(test.ColumnInfo.Name ==
"podQty"
)
{
this
.radGridView1.Columns[
"podName"
].HeaderText =
"Name"
;
this
.radGridView1.Columns[
"podTime"
].HeaderText =
"Time"
;
this
.radGridView1.Columns[
"podDate"
].HeaderText =
"Date"
;
this
.radGridView1.Columns[
"podQty"
].HeaderText =
"*Qty"
;
}
else
{
this
.radGridView1.Columns[
"podQty"
].HeaderText =
"Qty"
;
}
}
then in the cell formatting event look if the first character of the cell is a "*"
private
void
radGridView1_ViewCellFormatting(
object
sender, CellFormattingEventArgs e)
{
if
(e.CellElement
is
GridHeaderCellElement)
{
try
{
//var test = e.Column.HeaderText.ToString();
var test = e.Column.HeaderText.ToString().Substring(0, 1);
if
(test ==
"*"
)
{
e.CellElement.DrawBorder =
true
;
e.CellElement.DrawFill =
true
;
e.CellElement.GradientStyle = Telerik.WinControls.GradientStyles.Solid;
e.CellElement.BackColor = Color.White;
// e.CellElement.ForeColor = Color.Red;
}
else
{
e.CellElement.ResetValue(LightVisualElement.DrawBorderProperty, ValueResetFlags.Local);
e.CellElement.ResetValue(LightVisualElement.DrawFillProperty, ValueResetFlags.Local);
e.CellElement.ResetValue(LightVisualElement.GradientStyleProperty, ValueResetFlags.Local);
e.CellElement.ResetValue(LightVisualElement.BackColorProperty, ValueResetFlags.Local);
e.CellElement.ResetValue(LightVisualElement.ForeColorProperty, ValueResetFlags.Local);
}
}
catch
(Exception)
{
//throw;
}
}