I want to change notification icon text on mouse hover using c#
e.g
NotifyIcon notifyicon;
notifyicon.Icon = (Icon)resManager.GetObject("test");
notifyicon.Visible = true;
if(a==b)
{
notifyicon.Text = "Both are equal";
}
else
{
notifyicon.Text = "Not equal";
}
Is it possible???
See the documentation for the ToolTip class on MSDN. The "Examples" section should contain the information you need.
Related
I have a first order menu item that is a chevron for toggling the state of a title panel. The menu item has ToolTipText that I want to change while the tool tip window is still open (i.e. hover active).
Is there a way to make this happen ?
Code
topMenuStrip.ShowItemToolTips = true;
chevronMenuItem.ToolTipText = "Hide title";
chevronMenuItem.Click += new System.EventHandler(titleToggle_Click);
private void titleToggle_Click(object sender, EventArgs e)
{
var mi = (ToolStripMenuItem)sender;
if (titlePanel.Visible)
{
titlePanel.Visible = false;
mi.ToolTipText = "Show title bar"; // does not change while hover active
mi.Image = Properties.Resources.chevron_expand;
}
else
{
titlePanel.Visible = true;
mi.ToolTipText = "Hide title bar"; // does not change while hover active
mi.Image = Properties.Resources.chevron_collapse;
}
}
Pictures
Third image is after the tooltip is rerendered after new hover (mouse leave chevron mouse enter chevron)
According to Microsoft documentation, you must set the property AutoToolTip = false and the property ShowItemToolTips = true.
ToolStripItem uses the Text property as the default source for the
ToolTip content. Set AutoToolTip to false to use ToolTipText as the
source for ToolTip content.
To use this property, you must also set ShowItemToolTips to true.
Source: ToolStripItem.AutoToolTip Property
Currently I am using an application which play ppt and flash in WebBrowser Control.
In WebBrowser I am able to hide context menu by using
this.IsWebBrowserContextMenuEnabled = false;
and capture key event by using
this.PreviewKeyDown += new PreviewKeyDownEventHandler(IWebBrowser_PreviewKeyDown);
but while playing the ppt, both context menu and keypress events are not functioning i.e. I can see context menu and arrow key force the ppt to change the slide.
Again while playing flash, context menu is visible and I can handle key event. is there any other setting to it can same for whatever (HTML, PPT, Flash, PDF) is playing in webBrowser?
Edit :1
Here is my existing code
class IWebBrowser : WebBrowser
public IWebBrowser(RegionOptions options)
{
try
{
this.Width = 600;
this.Height = 400;
this.IsWebBrowserContextMenuEnabled = false;
this.ScrollBarsEnabled = false;
this.ScriptErrorsSuppressed = true;
this.WebBrowserShortcutsEnabled = false;
this.AllowNavigation = true;
CreateContextMenu();
this.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(IWebBrowser_DocumentCompleted);
this.PreviewKeyDown += new PreviewKeyDownEventHandler(IWebBrowser_PreviewKeyDown);
}
catch (Exception ex)
{
log.Error("IWebBrowser - ctor ", ex);
}
}
private void CreateContextMenu()
{
ContextMenuStrip myContextMenu = new ContextMenuStrip();
this.ContextMenuStrip = myContextMenu;
ToolStripMenuItem myFirstTooltip = new ToolStripMenuItem();
ToolStripMenuItem mySecondTooltip = new ToolStripMenuItem();
ToolStripMenuItem myThirdTooltip = new ToolStripMenuItem();
myFirstTooltip.Text = "Item One";
mySecondTooltip.Text = "Item Two";
myThirdTooltip.Text = "Item Three";
myContextMenu.Items.Add(myFirstTooltip);
myContextMenu.Items.Add(mySecondTooltip);
myContextMenu.Items.Add(myThirdTooltip);
}
context menu Images for different controls played in webbrowser
Display a webpage..................
flash played in webbrowser.................
ppt played in webbrowser.....................
Follow these steps to get rid of the default context menu
Do what you've done to hide default context menu
this.IsWebBrowserContextMenuEnabled = false;
Add a ContextMenuStrip control to your window and give a name (let's say MyMenu)
Set your browser control's ContextMenuStrip property to MyMenu
Now, whatever the document type you display on your Browser control it'll only display your custom menu.
Hope this helped!
All the best
Override all the mouse event flags Here is an example I hope this example will help you
You've to catch the PreviewKeyDown event in your WebControl where is playing your ppt/flash and rise it to the content page or whatever.
You can check how:
define Custom Event for WebControl in asp.net
The Message Boxes of WPF could be customized as i understand.
I was wondering is it possible to add a CheckBox to the WPF MessageBox with say - Don't show this message again etc.?
Possible, you can change the WPF control styles and templates as per your requirement, see these links for further references:
Custom Message Box
http://blogsprajeesh.blogspot.com/2009/12/wpf-messagebox-custom-control.html
http://www.codeproject.com/Articles/201894/A-Customizable-WPF-MessageBox
http://www.codeproject.com/Articles/22511/WPF-Common-TaskDialog-for-Vista-and-XP
Could just use a Window
Passed checked in the ctor so you can get the value back
bool checked = false;
Window1 win1 = new Window1(ref input);
Nullable<bool> dialogResult = win1.ShowDialog();
System.Diagnostics.Debug.WriteLine(dialogResult.ToString());
System.Diagnostics.Debug.WriteLine(checked.ToString());
I realize this is a very old thread, but I was searching this matter today and was surprised to see no replies mentioning Ookii: https://github.com/ookii-dialogs/ookii-dialogs-wpf
I was already using it for Folder Browsing. Now I wanted to add a "Don't Show Again" checkbox whenever the main window is closed, and it's really simple to use it.
Here's my code:
using Ookii.Dialogs.Wpf;
//create instance of ookii dialog
TaskDialog dialog = new();
//create instance of buttons
TaskDialogButton butYes = new TaskDialogButton("Yes");
TaskDialogButton butNo = new TaskDialogButton("No");
TaskDialogButton butCancel = new TaskDialogButton("Cancel");
//checkbox
dialog.VerificationText = "Dont Show Again"; //<--- this is what you want.
//customize the window
dialog.WindowTitle = "Confirm Action";
dialog.Content = "You sure you want to close?";
dialog.MainIcon = TaskDialogIcon.Warning;
//add buttons to the window
dialog.Buttons.Add(butYes);
dialog.Buttons.Add(butNo);
dialog.Buttons.Add(butCancel);
//show window
TaskDialogButton result = dialog.ShowDialog(this);
//get checkbox result
if (dialog.IsVerificationChecked)
{
//do stuff
}
//get window result
if (result != butYes)
{
//if user didn't click "Yes", then cancel the closing.
e.Cancel = true;
return;
}
Is there a simple way to create and show a custom tooltip control in C# / WinForms?
My current thinking is either:
create a subclass of Tooltip,
override the OnPaint method, set it
as the parent control's tooltip
create a subclass of form and show
it manually
Any thoughts?
It depends on what you need for your tool tip. If you only need a tool tip with balloon shape, animation and fading effects with custom text color and background, It is easier to use ToolTip control
// Create your control
System.Windows.Forms.Button trialButton = new Button();
trialButton.Text = "Trial Button";
// Tool tip string
string toolTipText = "Hello World";
// ToolTip toolTip = new ToolTip(this.components);
ToolTip toolTip = new ToolTip();
toolTip.ToolTipTitle = "ToolTip Title";
toolTip.UseAnimation = true;
toolTip.UseFading = true;
toolTip.IsBalloon = true;
toolTip.Active = true;
toolTip.SetToolTip(button, toolTipText);
I want to add a tooltip using ToolTip class on a column of a grid in winforms.
I want this because I need to extend duration of builtin grid tooltip in radgridview. If you can help me in settings the time of builtin tooltip of grid then it would also be sufficient.
EDIT: Can anybody just tell me that is it possible or not?
Thanks.
It's possible to add a ToolTip to an existing control. I've never used radgridview, so I can only give you a general direction to head.
ToolTip tooltip = new ToolTip();
tooltip.SetToolTip(grid, "your caption here");
tooltip.Popup += HandleToolTipPopup;
tooltip.AutoPopDelay = {time to display tooltip};
private void HandleToolTipPopup(object sender, PopupEventArgs e)
{
Point mouseLocation = Control.MousePosition;
Point relativeLocation = grid.PointToClient(mouseLocation);
// Check to see if it is within the area to popup on.
// Set e.Cancel to false if not.
}