private void СписокСообщений_SelectedIndexChanged(object sender, EventArgs e) { СписокСообщений.ToolTip = ""; if (СписокСообщений.SelectedIndex >= 0 && this.Visible) { bool этоОшибка = СписокСообщений.Items [СписокСообщений.SelectedIndex].ToString().Trim().ToLower().StartsWith("cs"); if (этоОшибка) { toolTipController.ShowHint(СписокСообщений.Items [СписокСообщений.SelectedIndex].ToString(), "Ошибка компиляции проекта"); } else { toolTipController.ShowHint(СписокСообщений.Items [СписокСообщений.SelectedIndex].ToString(), "Сообщение"); } } }
/// /// /// 冒泡提示 /// /// System.Windows.Forms的一个控件,在其上面提示显示 /// 提示的标题默认(温馨提示) /// 提示的信息默认(???) /// 提示显示等待时间 /// DevExpress.Utils.ToolTipType 显示的类型 /// DevExpress.Utils.ToolTipLocation 在控件显示的位置 /// 是否自动隐藏提示信息 /// DevExpress.Utils.ToolTipIconType 显示框图表的类型 /// 一个System.Windows.Forms.ImageList 装载Icon图标的List,显示的ToolTipIconType上,可以为Null /// 图标在ImageList上的索引,ImageList为Null时传0进去 public void NewToolTip(Control ctl, string title, string content, int showTime, DevExpress.Utils.ToolTipType toolTipType, DevExpress.Utils.ToolTipLocation tipLocation, bool isAutoHide, DevExpress.Utils.ToolTipIconType tipIconType, System.Windows.Forms.ImageList imgList, int imgIndex) { try { MyToolTipClt = new DevExpress.Utils.ToolTipController(); args = MyToolTipClt.CreateShowArgs(); content = (string.IsNullOrEmpty(content) ? "???" : content); title = string.IsNullOrEmpty(title) ? "温馨提示" : title; MyToolTipClt.ImageList = imgList; MyToolTipClt.ImageIndex = (imgList == null ? 0 : imgIndex); args.AutoHide = isAutoHide; MyToolTipClt.ShowBeak = true; MyToolTipClt.ShowShadow = true; MyToolTipClt.Rounded = true; MyToolTipClt.AutoPopDelay = (showTime == 0 ? 2000 : showTime); //MyToolTipClt.SetToolTip(ctl, content); //MyToolTipClt.SetTitle(ctl, title); //MyToolTipClt.SetToolTipIconType(ctl, tipIconType); //MyToolTipClt.SetToolTipIconType(ctl, tipIconType); MyToolTipClt.Active = true; MyToolTipClt.HideHint(); MyToolTipClt.ShowHint(content, title, ctl, tipLocation); } catch (Exception ex) { //CommonFunctionHeper.CommonFunctionHeper.CreateLogFiles(ex); MessageBox.Show(ex.Message); } }
static void richEditControl1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e) { RichEditControl richEdit = sender as RichEditControl; System.Drawing.Point docPoint = DevExpress.Office.Utils.Units.PixelsToDocuments(e.Location, richEdit.DpiX, richEdit.DpiY); DocumentPosition pos = richEdit.GetPositionFromPoint(docPoint); if (pos == null) { return; } string currentToolTipText = String.Format("Position: {0}, Character: {1}", pos.ToString(), richEdit.Document.GetText(richEdit.Document.CreateRange(pos, 1))); DevExpress.Utils.ToolTipControlInfo info = new DevExpress.Utils.ToolTipControlInfo(currentToolTipText, currentToolTipText); info.ToolTipPosition = System.Windows.Forms.Form.MousePosition; testToolTipController.ShowHint(info); }