void gridView1_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e) { if (e.Column.FieldName == "Employee") { ABCUserInfo user = gridView1.GetRow(e.RowHandle) as ABCUserInfo; if (user == null) { return; } SolidBrush brush = new SolidBrush(e.Appearance.BackColor); e.Graphics.FillRectangle(brush, (e.Cell as DevExpress.XtraGrid.Views.Grid.ViewInfo.GridCellInfo).Bounds); if (user.IsOnline) { e.Graphics.DrawImage(ABCControls.ABCImageList.GetImage16x16("Online"), e.Bounds.Location); } else { e.Graphics.DrawImage(ABCControls.ABCImageList.GetImage16x16("Offline"), e.Bounds.Location); e.Appearance.ForeColor = Color.Gray; e.Appearance.Options.UseForeColor = true; } Rectangle r = e.Bounds; r.Width -= 18; r.X += 18; e.Appearance.DrawString(e.Cache, e.DisplayText, r); e.Handled = true; } }
void gridView1_Click(object sender, EventArgs e) { Point pt = gridControl1.PointToClient(Control.MousePosition); GridHitInfo info = gridView1.CalcHitInfo(pt); if (info != null && info.Column != null && info.InRow || info.InRowCell) { if (info.Column.FieldName == "Employee") { ABCUserInfo user = gridView1.GetRow(info.RowHandle) as ABCUserInfo; if (user == null) { return; } if (ChatScreen != null) { ChatScreen.OpenChatBox(user.User); ChatScreen.ActiveChatPanel(user.User); } } } }