One: The first column shows the line number Customdrawrowindicator
This.gridViewDevice.IndicatorWidth = 40;
This.gridviewdevice. customdrawrowindicator + = new DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventHandler ( Gridviewdevice_customdrawrowindicator);
void Gridviewdevice_customdrawrowindicator (object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
{
if (e.info.isrowindicator && e.rowhandle >= 0)
{
E.info.displaytext = convert.tostring (Convert.ToInt32 (e.rowhandle.tostring ()) + 1);
}}
Two: Do not show different background color RowStyle
private void Gridview1_rowstyle(object sender, DevExpress.XtraGrid.Views.Grid.RowStyleEventArgs e)
{
DevExpress.XtraGrid.Views.Grid.GridView view = sender as DevExpress.XtraGrid.Views.Grid.GridView;
if (e.rowhandle >= 0)
{
String category = view. Getrowcelldisplaytext (E.rowhandle, view. columns[" field name "]);
if (category = = " condition of the display Color ")
{
E.appearance.backcolor = Color.lightgreen;
}
}}
Three: Different cells display different background color Rowcellstyle
private void Gridview1_rowcellstyle (object sender, Rowcellstyleeventargs e)
{
GridView View = sender as GridView;
if (E.column.fieldname = = " bound field ")
{
String category = View.getrowcelldisplaytext (E.rowhandle, view.columns[" field name "]);
if (category = = " meet field Conditions ")
{
E.appearance.backcolor = color.lightcoral;
E.appearance.backcolor2 = Color.lightpink;
}}}
Four: Add Column icon Customunboundcolumndata
Add icon column, FieldName set to Image
Hashtable Images = new Hashtable (); Icon Collection
private void Gridview1_customunboundcolumndata (object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDataEventArgs e)
{
if (E.column.fieldname = = "Image" && e.isgetdata)
{
String Condition = (string) ((DataRowView) e.row) [ lookup field ]. ToString ();
String fileName = "1.png";
Switch ( conditional )
{
Case "1":
FileName = "1.png";
Break
Case "2":
FileName = "2.png";
Break
}
if (! Images.containskey (FileName))
{
Image img = null;
Try
{
String FilePath = System.IO.Path.Combine (Application.StartupPath.ToString (), @ "Resource\icon", fileName);
img = Image.FromFile (filePath);
}
catch{}
Images.add (FileName, IMG);
}
E.value = Images[filename];
}
}
DevExpress GridView Summary (i)