|
In your code, you are using
richTextBoxText.Select(0,0);
which is making the cursor to go to the top of the text (i.e., the position of 0 with the selected length of 0, which means simply moving the cursor over there). Try removing this last line of code.
Otherwise, the method is very simple, first select the portion whose color is to be changed. And, then use the SelectionColor property. For example-
richTextBox.Select(5,15);
richTextBox.SelectionColor = Color.Blue;
These lines of code will change the color of the text starting at point 5 and with a length of 15 characters.
|
|
|
|
|
that is what I did first time, but then the text is marked, and that is what i wanted to get rid of!
QzRz
|
|
|
|
|
Hallo, here I am with onother strange question!
You may think: "he's full of questions..."
Now the problem is quite simple: I'm using an rtf textbox. If I change the font property all of the text assumes the new changes. How cna I change font name, size, style and color from the position the curso is without changing the font property of all the text?
Thanks
CometKeeper
|
|
|
|
|
The RichTextBox has several properties starting with Selection (e.g. SelectionColor ). If no selection is present those properties won't have any immidiate visible effect, but will do what you are trying to achieve.
|
|
|
|
|
How can I get results written by a console application in order to display on another application, a textbox, for instance?
|
|
|
|
|
you can use this:
System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo info = new System.Diagnostics.ProcessStartInfo();
info.FileName = "CommandLineApplication.exe";
info.CreateNoWindow = true;
info.RedirectStandardInput = true;
info.RedirectStandardOutput = true;
process.StartInfo = info;
process.Start();
to retrieve the results use process.StandardOutput.ReadToEnd(); or the other ReadX() methods
_______
http://www.jockersoft.altervista.org
|
|
|
|
|
I would like to display each line as the console app is running, the ReadLine method seems to work, but I recieved only one line, the ReadToEnd method waits until the console app ended to display its results.
Any suggestion?
|
|
|
|
|
Description
I'm trying to process a KeyPressed event on a form
sent to my user control. After the processing of
the event, I want to send the keystock to a textbox
on the form.
I can ,of course, access the text property of the
text box but I wanted to know how can I do it in
another way.
Question
How can I access the text box and give it the keystrock
as if it has the focus and I only pressed a key on the form.
I understand that when a form get a key, it looks for
the control with the focus and send him the key, or event.
How can I emulate that, so I can send a key after I processed
it, to other control or controls?
|
|
|
|
|
You'll need to use PInvoke and use SendMessage[^] to send the TextBox a WM_CHAR[^] message
[DllImport("User32.dll")]<br />
public static extern IntPtr SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);<br />
<br />
public void SendTextBoxKeyPress()<br />
{<br />
SendMessage(textbox.Handle, 0x0102 , (int) Keys.Enter, 0);<br />
}
"I think I speak on behalf of everyone here when I say huh?" - Buffy
|
|
|
|
|
is it a fantasy?
If it is not possible how about getting the Width or X,Y coordinates of the notification area (systray) ?
|
|
|
|
|
You don't need to P/Invoke win32 APIs to get this to work. The NotifyIcon component provides a MouseDown and MouseUp event which you could handle, and that provides your X and Y coordinates through the MouseEventHandler . You could, in one example, cache the X and Y coordinates when the mouse is clicked down on the systray icon and when the Click event fires you can retrieve that. An example is shown below. You could also coordinate your own client event handler, but this requires extra code that would not be necessary.
notifyIcon1.MouseDown += new MouseEventHandler(notifyIcon1_MouseDown);
notifyIcon1.Click += new EventHandler(notifyIcon1_Click);
Point p;
private void notifyIcon1_MouseDown(object sender, MouseEventArgs e)
{
p = new Point(e.X, e.Y);
}
private void notifyIcon1_Click(object sender, EventArgs e)
{
MessageBox.Show(string.Format("The user clicked at {0} within the icon.", p));
}
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Thanks Heath, that is nice. But what if the user does not click on the notifyicon? I need to know the location even if the icon is not clicked. Can I emulate/simulate a click?
I am also interested in finding a way to get the width and location of the entire systray (aka notification tray) area. I am trying to emulate the behavior of Windows Messenger when it is closed. You will see how it "animates" the close, thus showing the user that the window is actually being minimized to the systray.
Thanks again, Tom.
|
|
|
|
|
You'll need to register a hook into the Windows system message loop. Your application - without using a hook or some sort of inter-process communication (IPC) - will only receive events that occur within the main application or child windows (including controls, which are child windows).
See Global System Hooks in .NET[^] for a good article that describes how to register hooks and that includes sample code.
If you want to find articles on Messenger-style notification windows, search for "messenger[^]", for example, on this site. You'll find several good articles and sample code.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Use the hook to simulate a mouse click on the systray icon?
Or use a hook to get the width of the entire systray?. I read the article and cannot turn up how to do either of these tasks. Please advise. Thanks for your help so far.
|
|
|
|
|
From your previous post:But what if the user does not click on the notifyicon? I need to know the location even if the icon is not clicked. Can I emulate/simulate a click? The first two sentances do not agree with the concept of the third. The hook is to register yourself to receive notification when a user clicks outside of your client area. If you want to simulate a click, the easiest way is to simply call your Click event handler, or the method that contains the code you want done when a user clicks your icon.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
I'm a binger,I has three question.
1.How to do a abnormity form,I know draw it in region,but the performance is poor,there are better method?
2.In richtextbox control,how to display highlight keywords and linenumber?
thanks.
|
|
|
|
|
I hate repeating myself. From your first post:
1) I have no idea what you mean by an "abnormity form"...
You might want to explain what you mean by this.
3) Look at the SelectionStart , SelectionLength , and SelectionColor properties.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I am working on a C# project that looks for words in a text file.
The current design is that my RegEx will need to be called 3 times to search for 3 different patterns:
\bWord1\b then \bWord2\b followed by \bWord3\b
Is there any OR operator that will allow me to specify all 3 words in a single RegEx pattern?
|
|
|
|
|
|
I recommend that you read about Regular Expressions[^] in the .NET Framework SDK.
You really don't need to search 3 times, if I understand your logic correctly. You just need to find Word1, Word2, and Word3 one after another:
Regex re = new Regex(@"\bWord1\b.*\bWord2\b.*\bWord3\b");
Match m = re.Match("This is a sentence with Word1, then Word2, and followed by Word3.");
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
I would like to exercise the article "Your first C# Web Service", By Chris Maunder.
I am using XP and I have IIS turned on. When I try to create a Web Service via the Microsoft Visual Studio .Net 2003 I get the error.
‘Visual Studio cannot create or open the application because the Web server on this computer is not running. Start the Web Server before proceeding.’
The directions under the help button direct me to
‘On the Web server computer, open Control Panel and then choose Internet Services Manager.’
I do not have an option labeled ‘Internet Services Manager’. I have downloaded the Microsoft .NET Framework 1.1 plus its patches.
Does creating a Web Service require me to run Windows 2003 Server or something like that?
Thanks
|
|
|
|
|
Look under Administrative Tools in Control Panel, or just open a command prompt and type:
net start w3svc
Good luck.
The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’
|
|
|
|
|
Thank you.
This command results in a system error 1717.
I did attempt all the suggestions in the MSDN Help. I think I am missing a Windows Component, but I am not sure what or how to get it.
thanks
|
|
|
|
|
If this ain't too late.. goto add remove components in control panel and install IIS.. then ul find it in Admin tools in control panel
|
|
|
|
|