Change tool tip timeout on menustrip in winforms? - winforms

How to extend tool tip timeout when hovering on menu items in a menustrip (in winforms)?
I set it like this:
toolStripMenuItem1.ToolTipText = "foo";

You can do it if you use the Tooltip class, by setting the AutoPopDelay property to a higher value (MSDN: Change the Delay of the Windows Forms ToolTip Component).
However, if you try to use the Tooltip class to set a tooltip on a ToolStripMenuItem like this:
ToolTip1.SetToolTip(toolStripMenuItem1, "check it yo!")
You'll get the following error:
'System.Windows.Forms.ToolStripMenuItem' cannot be
converted to 'System.Windows.Forms.Control'.
Check out this StackOverflow question for ways around that.

There is an article on CodeProject that implements a derived version of ToolStrip with custom tool tip support. That could probably be used to do what you want to do.
http://www.codeproject.com/Tips/376643/ToolStrip-with-custom-ToolTip

Related

How to get the old value of a TrackBar without a custom control or separate field?

I am trying to get the old Value of a TrackBar when the Scroll event gets raised. I could do this by creating a separate field and storing that value whenever it changes, or overriding the event in a custom control however, I am already using the built-in TrackBar and I'd prefer to not have to redesign my forms.
The Microsoft documentation does not seem to have any information on this and the EventArgs parameter on the OnScroll and OnValueChanged methods seem pretty generic.
Is there a way to achieve this and how?
Sources:
Microsoft Documentation: TrackBar.OnScroll Method
Microsoft Documentation: TrackBar.Scroll Event
How to override method and event in WinForm UserControl in C#?
Microsoft Documentation: TrackBar.ValueChanged Event
Microsoft Documentation: TrackBar.Value Property
Microsoft Documentation: TrackBar.OnValueChanged Method
I believe there isn't a built-in way to achieve what you're looking for.
To address your concern about having to replace all the TrackBar controls on a form with the derived custom control, here's how I usually do it:
Create your control class which inherits the TrackBar control.
Open your FormName.Designer.cs or FormName.Designer.vb file.
Click Ctrl+H to open the "Find and replace" window.
Enter System.Windows.Forms.TrackBar in the "Find" field, and YourNameSpace.CustomTrackBar in the "Replace with" field.
Click "Replace all" (You can do it one by one if you're afraid to mess something up).
Rebuild your project.
Hope that helps.

Button custom attributes for windows forms

I need to add a secondary Id or even some custom text to controls like Button, Textbox, ListBox etc., so that i can later use it for programmatic purposes and should not be displayed to user.
I can do this in ASP.net using Attributes property for almost any control, but when I checked with windows forms I found it doesn’t have this property, can I find any other alternatives in windows forms?
You can use Control.Tag property for this.
myButton.Tag = whatever;
myTextBox.Tag = whatever;
...
Use the Control.Tag property. Source: MSDN
"A common use for the Tag property is to store data that is closely associated with the control."
This sounds like what you're after.

WPF: Custom window, standard min/max/close buttons

I would like to create a custom WPF window (WindowStyle = None, AllowsTransparency = True). However, I would like the min/max/close buttons to look identical to those on standard windows. Is this possible?
You might want to have a look at GlassWindow in FluidKit at CodePlex
http://fluidkit.codeplex.com/
The source code has a custom Window Style looking like this. It's pretty easy to modify to however you want it to look. I've used it once and it works good
You'll need to "draw" them yourself, since you're using WindowStyle=None. When choosing this option, you'll need to render your own Chrome as desired.

Blend Slider Control

Is there a free implementation of the text box in Blend's property grid that allows you to change the number by clicking and dragging? Or perhaps another way to ask is what kind of control called so I can google it?
just try this
http://www.codeproject.com/KB/WPF/MicrosoftBlendStyleTextBo.aspx
It's called a numeric UpDown control. (Terrible name, I know).
MS has a sample implementation for WPF, although I think you'll have to provide the draggable part yourself.

WinForms "mini-windows"

I need to create some mini-windows, like the ones shown in the image bellow, in my winform main form.
It would be nice if they could be draggable, resizable, and, mainly, closable.
How can I approach this design? Has anybody already seen some control (with code available) implementing something similar?
alt text http://img716.imageshack.us/img716/5765/imagea.png
A normal Form works fine for this. Set its FormBorderStyle to either FixedToolWindow or SizableToolWindow as desired.
If you want to keep your floating windows inside your main window, use MDI (Multiple Document Interface). Here is a tutorial (Google can find you many more).
Have you tried just setting the FormBorderStyle property to SizeableToolWindow?
Is that what you're after?
You can create them as resizable and draggable custom controls.
You could use my example at:
http://hourlyapps.blogspot.com/2008/07/resizable-and-movable-controls-c-net.html

Resources