does someone know, how to make various parts of RichTextBox text to blink in .NET on Winforms?
Or maybe this is already done?(Google gave no help)
Thank you
First you need a timer. after selecting a text and click the blink button save the region of the text (startposition:endposition) to an array. With the timer change every second(for example) the color of the text in regions saved in the array. if the text is changed check if the change occured in a region and inrecrease or shrink the region. if the text is change outside a region check if the blinking text is moved and move the region also backward/foreward.
Related
Is there any easy way to implement editable text field in Win2D?
I'm trying to make a simple text tool, which would add text over image (just like in MS Paint).
By clicking inside the text's boundaries, it'd make that text ´selected`. Selected text would draw lines around it's area according to it's boundary box, and start blinking a caret in the clicked position. By clicking elsewhere, it'd unselect the text (hides possible caret, text selection and boundary box).
I was thinking about a simple solution with XAML TextBox, but I'm afraid that it doesn't support all of the effects that Win2D does (f.ex warping the text).
What would be the correct way to do it?
I'm creating a WinForms inventory application where the user can enter data into a series of textboxes for every new item they want to add or existing item they want to edit.
One of the textboxes is for Comments about the item, and I'd like to let the user select this text color to be whatever they'd like when they add it to the inventory. Is there a way to do this other than something like:
1) User clicks a button next to the textbox
2) Button displays a list of predetermined colors (say Red, Green, & Blue)
3) User can click one of those and then it goes back and changes the textbox.text color property
I wasn't sure if Visual Studio had some neat built-in colorwheel control that would return the selected color for me, or if the way I described is the simplest, most straightforward way to do it. (I'm assuming one thing I'll probably need is to use a Rich Text Box instead of a Text Box?)
I think you're looking for ColorDialog .
ColorDialog cd= new ColorDialog();
if (cd.ShowDialog() == DialogResult.OK)
textBox1.ForeColor = cd.Color;
My recommendation is - don't.
If you go with Rich Text, then it will become a real pain in the rear when you need to generate reports!!! Most report generators cannot process rich text.
It's probably best to skip over "features" like this comments color change and leave things at default. You might embellish by font size, or bold / underline / italics, or decorating around the text box, but leave the text generic. Eventually you'll run into a user who can't see the text because a selected Windows desktop color profile makes their custom color invisible -- and who gets blamed??? The developer.
Spot this kind of issue way before it happens, and you'll save yourself a lot of grief.
I am using a WFA which has a ToolStripMenuItem that is supposed to search for a word in a textBox and highlight it. This is the highlighting code.
first = first index to be highlighted
, length= number of characters to be highlighted.
textBox2.SelectionStart = first;
textBox2.SelectionLength = length;
//scroll to the caret
textBox2.ScrollToCaret();
everything seems to be working well. However, If the mouse cursor isn't inside textBox2 (say in another textBox). The highlighting doesn't work. Is there a way to make it work regardless of the position of the mouse cursor? in other words, is there a way to change my code to make it highlight the text in textBox2 even if the mouse cursor wasn't inside textBox2 before hitting the ToolStripMenuItem?
P.S. It's worth mentioning that I am using c# in VS 2010
Try:
textBox2.Focus();
before you run the code that highlights the text. This will move input focus (and your cursor) to the textbox
just use richtextbox and change the backcolor of the text.
this way you can use multiple highlights at a time and the highlight won't be lost after the user focus the textbox by mouseclick. Additionally you can save all postions and automatically select the textpart if the user clicks into the highlighted area.
you can also show the selection like LarsTech mentioned, but after the user clicks inside the textbox the selection will get lost.
I'm trying to color a specific line's background in a RichTextBox.
I need the line's background to be colored all the way to the end of the right side of the control.
I tried using the SelectionBackColor property, but it colors only until the end of the line.
Does anybody know of a way to do this?
thanks :)
mmm, I believe you cannot do it without some custom painting, because as you said, with RTF formatting you format text so if you do not have text ( chars or white spaces or tabs... ) you cannot reach those parts of the control which are completely empty, unless you do change the whole control background color...
Bit messy, but if you don't want to go ahead with custom painting the control. You could make the textbox transparent, then add an image behind the control which has the line selected. You could then change the Image.Location.Y value on the TextChanged event.
Customizing the stock Windows rich text control is possible, but they didn't make it easy. If I were you, I would do what I did: Purchase a better text control.
Consider my windows application built using C# VS 2005 displays certain contents in a multi lined text box. Now when i add some new text, it should appear in a different colour. i.e i need to differentiate the text which gets displayed when my project is run and the text that i enter in the text box. how can i do this.?
The plain TextBox control doesn't support multiple colours, fonts etc.
I suspect you'll need to use a RichTextBox instead. You can then set the SelectionColor property to change the colour of the currently selected text or text inserted at the current insertion point.
I should add that after a few quick experiments, I've found that setting the selection colour and then immediately appending text programmatically doesn't work quite as straightforwardly as I'd hoped. Maybe another answer will explain why :) However, text entered by the user certainly appears in the new colour immediately...