//in this method a tooltip for the items of the combo is drawn void Editor_DrawItem(object sender, DevExpress.XtraEditors.ListBoxDrawItemEventArgs e) { ComboBoxEdit cboEditor = sender as ComboBoxEdit; EM_UI_MainForm mainForm = cboEditor.Parent.Parent as EM_UI_MainForm; if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) { //search for the Comment, it should go into the tooltip var parameterRowComment = from parameterRow in GetParameterRowsILs() where parameterRow.Value.Equals(e.Item.ToString()) select parameterRow; if (parameterRowComment.Count() == 0) { parameterRowComment = from parameterRow in GetParameterRowsTUs() where parameterRow.Value.Equals(e.Item.ToString()) select parameterRow; } if (parameterRowComment.Count() == 1) { mainForm.lblComboboxEditorToolTip.Text = GetILTUComment(parameterRowComment.First()); mainForm.lblComboboxEditorToolTip.Visible = true; int y = mainForm.treeList.Location.Y + cboEditor.Location.Y + e.Bounds.Bottom + 5; int x = cboEditor.Location.X + e.Bounds.Right + 25; mainForm.lblComboboxEditorToolTip.Location = new Point(x, y); mainForm.lblComboboxEditorToolTip.BringToFront(); } else { mainForm.lblComboboxEditorToolTip.Visible = false; } } }
void Properties_DrawItem(object sender, DevExpress.XtraEditors.ListBoxDrawItemEventArgs e) { if (disabledItems.Contains(e.Item.ToString())) { e.Appearance.ForeColor = Color.Gray; } }
private void secondaryPrimaryVariableListBoxControl_DrawItem(object sender, DevExpress.XtraEditors.ListBoxDrawItemEventArgs e) { ListBoxControl listBox = sender as ListBoxControl; if (listBox.Enabled && e.State != (DrawItemState.Focus & DrawItemState.Selected)) { e.Appearance.BackColor = Color.SlateGray; } }
/// <summary> /// 列表控件显示月份 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public static void lbMonth_DrawItem(object sender, DevExpress.XtraEditors.ListBoxDrawItemEventArgs e) { var lb = sender as ListBoxControl; DateTime date; if (!DateTime.TryParse(lb.GetItemText(e.Index), out date)) { return; } string s = date.ToString("yyyy年MM月"); e.Appearance.DrawBackground(e.Cache, e.Bounds); e.Graphics.DrawString(s, e.Appearance.Font, e.Cache.GetSolidBrush(e.Appearance.ForeColor), e.Bounds.Location); e.Handled = true; }
private void tp04_cboClass_DrawItem(object sender, DevExpress.XtraEditors.ListBoxDrawItemEventArgs e) { if (e.State != DrawItemState.Selected) { //e.Cache.FillRectangle(new LinearGradientBrush(e.Bounds, Color.Black, Color.FromArgb(88, 88, 88), LinearGradientMode.Horizontal), e.Bounds); e.Cache.FillRectangle(new SolidBrush(Color.Black), e.Bounds); if (e.Item.ToString().StartsWith("[S]")) { e.Cache.DrawString(e.Item.ToString(), e.Appearance.Font, new SolidBrush(Color.FromArgb(128, 128, 255)), e.Bounds, e.Appearance.GetStringFormat()); } else if (e.Item.ToString().StartsWith("[I]")) { e.Cache.DrawString(e.Item.ToString(), e.Appearance.Font, new SolidBrush(Color.FromArgb(255, 166, 77)), e.Bounds, e.Appearance.GetStringFormat()); } else if (e.Item.ToString().StartsWith("[E]")) { e.Cache.DrawString(e.Item.ToString(), e.Appearance.Font, new SolidBrush(Color.FromArgb(255, 128, 128)), e.Bounds, e.Appearance.GetStringFormat()); } } else { if (e.Item.ToString().StartsWith("[S]")) { e.Cache.FillRectangle(new LinearGradientBrush(e.Bounds, Color.Black, Color.FromArgb(128, 128, 255), LinearGradientMode.Horizontal), e.Bounds); } else if (e.Item.ToString().StartsWith("[I]")) { e.Cache.FillRectangle(new LinearGradientBrush(e.Bounds, Color.Black, Color.FromArgb(255, 166, 77), LinearGradientMode.Horizontal), e.Bounds); } else if (e.Item.ToString().StartsWith("[E]")) { e.Cache.FillRectangle(new LinearGradientBrush(e.Bounds, Color.Black, Color.FromArgb(255, 128, 128), LinearGradientMode.Horizontal), e.Bounds); } e.Cache.DrawString(e.Item.ToString(), e.Appearance.Font, new SolidBrush(Color.White), e.Bounds, e.Appearance.GetStringFormat()); } e.Handled = true; }