private void OnGetActiveObject(object sender, DevExpress.Utils.ToolTipControllerGetActiveObjectInfoEventArgs e) { if (e.SelectedControl == checkedComboBoxEdit1) { PopupContainerEditViewInfo editInfo = checkedComboBoxEdit1.GetViewInfo() as PopupContainerEditViewInfo; EditHitInfo hitInfo = editInfo.CalcHitInfo(e.ControlMousePosition); if (hitInfo.HitTest == EditHitTest.MaskBox) { object val = checkedComboBoxEdit1.EditValue; if (val == null || val == DBNull.Value || val.Equals(string.Empty)) { return; } string[] checkedItems = checkedComboBoxEdit1.Text.Split(separatorChar); Rectangle rect = editInfo.MaskBoxRect; string description = GetCheckedItemDescription(checkedItems, editInfo.PaintAppearance.Font, e.ControlMousePosition, rect); int itemIndex = GetItemIndex(checkedComboBoxEdit1, description); if (itemIndex == -1) { return; } ToolTipControlInfo tInfo = tInfo = new ToolTipControlInfo(); tInfo.Object = itemIndex; tInfo.SuperTip = GetSuperToolTip(checkedComboBoxEdit1, (carsBindingSource.DataSource as DataTable).Rows[itemIndex]); e.Info = tInfo; } } }
protected override void DrawString(ControlGraphicsInfoArgs info, Rectangle bounds, string text, DevExpress.Utils.AppearanceObject appearance) { PopupContainerEditViewInfo viewInfo = info.ViewInfo as PopupContainerEditViewInfo; RepositoryItemCheckedImageComboBoxEdit edit = viewInfo.Item as RepositoryItemCheckedImageComboBoxEdit; if (!edit.CanShowImageInEditBox) { base.DrawString(info, bounds, text, appearance); } else { DrawContent(info, bounds, text, appearance); } }
private void DrawContent(ControlGraphicsInfoArgs info, Rectangle bounds, string text, DevExpress.Utils.AppearanceObject appearance) { PopupContainerEditViewInfo viewInfo = info.ViewInfo as PopupContainerEditViewInfo; RepositoryItemCheckedImageComboBoxEdit edit = viewInfo.Item as RepositoryItemCheckedImageComboBoxEdit; string[] values = text.Split(edit.SeparatorChar); Rectangle valRect = new Rectangle(bounds.X, bounds.Y, 0, bounds.Height); foreach (string val in values) { int index = GetIndexByDescription(edit.GetItems(), val.Trim()); if (index != -1) { DrawImage(edit, info.Graphics, index, ref valRect); } string str = val; if (Array.IndexOf(values, val) < values.Length - 1) { str = string.Concat(val, edit.SeparatorChar); } DrawString(info, appearance, ref valRect, str); } }