|
another good guy with goooooogle
You can load multiple files into RichTextBox one simple way :
load the files into separate buffers (dont use RichTextBox.LoadFile or something)... and then set's these buffers with the += .. :
System.IO.TextReader tr1 = new System.IO.StreamReader("filename1.txt");
string s1 = tr1.ReadToEnd();
...
richtextBox.Text += s1;
and so on
VirtualVoid.NET
|
|
|
|
|
Hello,
I am implementing a FileSystemWatcher to watch a directory for changes. The code that I wrote was as follows:
private void setupDirWatcher(string thePath)
{
FileSystemWatcher aWatcher = new FileSystemWatcher();
aWatcher.Path = thePath;
aWatcher.NotifyFilter = NotifyFilters.LastWrite;
aWatcher.Changed += new FileSystemEventHandler(aWatcher_Changed);
aWatcher.EnableRaisingEvents = true;
}
This is called once to do the setup and the intent was to have a watcher on a particular directory.
But I don't understand why this would ever work. It would seem to me that since aWatcher is a local variable and should go away at the end of the method, then the watcher shouldn't really work. I realize that 'new' is called here, but I don't see how this has any lifespan outside this method. What I see is that the event handler gets called several times, as changes happen in the directory.
I would have expected that aWatcher would need to be a class member for this to work. Is it just a coincidence that this works or am I missing something here?
Thanks,
Matt
|
|
|
|
|
The FileSystemWatcher instance is not collected by the garbage collector because of the event handler that is registered to the Changed event.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Thank you for your response. It was helpful.
Matt
|
|
|
|
|
The life span in C# is a lot different than in C/C++ or other non-garbage collected languages. The "aWatcher" is a pointer to the created instance, and that pointer will expire when the method is finished, while the lifespan if the instance will be as long as, in easy terms, "somebody knows where it is".
Internet - the worlds biggest dictionary
|
|
|
|
|
So in this case, the watcher instance's lifespan is until either the program terminates or I explicitly unregistered the event handler at some point later in the code and I guess that would need to be in the specified callback method itself since I don't actually have a way to get to that watcher instance once the setup method is done.
Thanks for the clarification on this.
|
|
|
|
|
Correct. Generally if you need to unregister an event handler you need to save the needed instance information in class variables.
--
Rules of thumb should not be taken for the whole hand.
|
|
|
|
|
OS :XP
Visual studio 2003
controls . RichTextbox
I have two richtextbox one is input and
other one is display.
I place some text in input then added
it will show in display window.
In display richtext I could not find the last send item.
the scroll is on the top
How can bring the scrollbar to down in run time.
for shwo the last send item from input richtext.
anybody help me
Continue...
|
|
|
|
|
textBox.Select(textBox.length, textBox.length);
i guess that will work
|
|
|
|
|
Hi
Is there any column like datagridDateTimePicker in vs-2003 version?
sivamyneni
|
|
|
|
|
FlexGrid can do something like this (www.componentone.com)
VirtualVoid.NET
|
|
|
|
|
didnt get anything from that
sivamyneni
|
|
|
|
|
you can code the customeditor(s) in that control (flexgrid)... there are a lot of good examples and explantations
VirtualVoid.NET
|
|
|
|
|
hi,
thank you.i got it.
sivamyneni
|
|
|
|
|
Hi Code project people,
can anyone help me out with how to page table control?
will be expecting your responses.
thanks in advance.
|
|
|
|
|
AFAIK you can't. Take a look at the DataGrid instead.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
how can i open(visualize) a System.Windows.Forms.MenuItem of System.Windows.Forms.MainMenu by code?
jaye
|
|
|
|
|
if this menuItem has other menuItems under it you use the following statment
<br />
menuItem1.ShowDropDown();<br />
if it doesn't have you show use the above statment on its parent menu item
|
|
|
|
|
|
jaimeaye wrote: sorry but this metod (ShowDropDown) isn´t appear in my Visual Studio 2003 C#.
It can't. The ShowDropDown method is member of the ToolStripMenuItem class that is new in .NET Framework 2.0.
I think the classes in Framework 1.1 provide no support for what you're trying to achieve, so you're somehow at a loss.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
I suggest you try MenuItem.PerformClick()
Luc Pattyn
|
|
|
|
|
|
jaimeaye wrote: with menuItem1.PerformClick(); you send a event of Click.
that's right, but if you do this on the parent menuItem it will do what you wish
cz the click event of the parent menu item is to open its drop down items.
for example if your have a File menu item and under it New.
if you like to view nuew you write:
fileMenuItem.PerformClick();
|
|
|
|
|
Did you tested this? I've tried and it doesn't work. Also the PerformSelect method doesn't show the menu.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Stefan Troschütz wrote: Did you tested this?
Sorry i didn't do that, but i assumed it will work.
anyway i will try to figure out another solution
|
|
|
|