I am using Windows Forms Application in C#
I have a label having Date as Text 16-12-2010
Now I want to display different Tooltip when mouse is over Date/Month/Year
e.g. When Cursor on Date : Then Today's Date
as Tooltip
UPDATED:
One Source of Example is When we vote
to Close any Question in
StackOverflow.com
Use multiple labels - one for each part.
Otherwise you're going to need to know which characters in the Label the mouse is over - different Font's render differently. That's a can-o-worms if ever there was one.
You can beak the label in 3 labels and set the tool tips as you like.
Related
I have a question...i'm trying to hover a specific word from a label with another label, but i don't know how to get the specific word position from the label's text. I would be very happy if you could help me at least, how to get the word location in the label. I have to say that the label Autosize is false, so it could have more than just one line. Thank you!
If I understand correctly, you want to reference one of the words in one label's .Text property and use it in another label when you hover over the first label.
If you know already what word in the string you want, it's easy. You can fetch it by the 0-indexed position of the letters, since a string is really just an array of type Char. You can also use String class tricks like .Substring() to fetch the word.
I think the degree of complexity you've added, though, is that (and correct me if I'm wrong) you want the second label to display the specific word over which the mouse is hovering while the mouse is hovering over the first label. That involves getting the label's coordinates as well as the pointer's, and a rather complex method for determining "what is a word, really?". If possible, I would split your source label into a label for each word. This can be done with dynamic labels by inheriting from the Label (or a container, like Panel) class in a custom control and giving it an IEnumerable of Labels as a property. Doing this, you can assign the OnHover handlers at runtime, and evaluate these events as individual labels rather than having to do the math and hope that a screen resolution change doesn't ruin your day.
I have got labels in my Windows Forms application which are placed next to controls.
When I change my language options to another language, the text needs more space now it covers my control.
Are there any ways to fix this problem?
No magic here I'm afraid. You have to try making your labels as (reasonably) wide as possible to accomodate each of your supported languages. Don't use AutoSize property here.
If labels appears on the left, have your text aligned to the right using the TextAlign property. This way they should always appear close to your control without ever overlapping them.
Also try to use containers to design your forms: TableLayoutPanel, FlowLayoutPanel. Controls that are placed in their cells, are autosized and wordwrapped correctly in most cases.
I would like to know how it is possible to replicate the text box used in windows 7, that is when you press a symbol it adds the numbers on the upper part of the text box. I tried adding a label in the text box but it still did not replicate the same effect. Can anyone please give me a hint to what I can try to achieve the same result.
Thanks
Use two textboxes and apply events to mathematical operator buttons. (and a graphic underneath if you feel fancy)
I don't think there is a control that can be just 'added', you could alternatively create your own, using a User Control template.
I am working on a page where I need to highlight different events in a day with different colors in a ASP.NET Calendar Cell. The events are store in a database with a start date column.
For example, if we have two different events for today, the cell should display half green and half red color. If there are three events for today, it would 1/3 green, 1/3 red, 1/3 blue in the cell for today.
In addition, currently I use tooltip in jquery to hover a cell, it would display a tooltip above the cell. How to handle this when we have different events in one cell?
All the answers are very much appreciated.
Thank you very much.
I think I could answer my own question. I used the DayRender event, and in that event, I did a select statement to get all the events information for each day of the calendars. I could get the number of events in one day from the select statement. Based on how many events on a day, I will add how many divs into the day cell; and based on number of events in one day, I can set the width of the div. In addition, when I added the divs, I added the class for the each div so that I can change the colors of each div.
The DayRender event on the calendar gives you full control of the cell. The calendar essentially amounts to a table structure; you will have to use DIV's within the container with a given fixed height and manually apply this logic. It may also be possible on the client, but I think the easiest is the server. It won't be easy, but should be possible.
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Watermarked Textbox for Compact Framework
Using Visual Studio 2008 SP1, the latest Compact framework and Windows Mobile 5.
I need to use DrawString to put a string over a TextBox. But as soon as I draw the string the TextBox Control just over writes it. (I Know because I drew slightly off the edge of the control and my text is half visible (where is is off the control) and half gone (where it is on the control.)
Is there anyway I can get the TextBox to not refresh so I can keep my text there?
NOTE: I have looked into subclassing TextBox and just having it paint my text. However, Paint events for the TextBox class are not catchable in the CompactFramework. If you know a way to be able to paint on the TextBox without the Paint events then I would love to subclass the TextBox class.
--End of Question--
Just in case you are wondering why I need to do this, here is what I am working on: I need to have a text box where a numeric value must be entered twice. I need some sort of clear clue that they have to enter the number again. I would like to have a slightly grayed out text appear over the text box telling the user to re-enter.
I have tried using a label, a hyperlink label and another text box, but they obscure the text below (which has a default value that has to be partially visible).
If anyone knows a different way cue for re-entry that would be great too!
Vacano
You can solve this problem in a different fashion. It sounds like you want to silhouette their previous input so they must type it again.
I don't know what strides the CF has made recently but if there is a RichTextBox then this method will work. If not you would have to write your own implementation starting with a base control.
Set the text of the RichTextBox to the silhouette value but make the text color gray for all the characters.
Capture the keypress events and as they press the correct key, change the text color for that character pressed from gray to black and discard that key press, and discard all other key presses.
This solution won't work if you want to allow them to go off the reservation, such as freeform text. Instead of discarding what they typed if they mistype or enter a different character you would not discard the keypress, but blank out the current and remaining gray characters thus allowing them to type with no silhouette.
As I answered in the closed dupe of this:
Where are you doing the DrawText? On the TextBox parent? If so, then that would be expected behavior. Why not create a custom TextBox control that paints (by overriding OnPaint) the value the first time, maybe in something like a light grey, then the second time paints it again in Black?