|
I need to load large string into RichTextBox.This string is RTF formatted text.If I try passing that string to RichTextBox like:
RichTextBox.Rtf=that string
RichTextBox freeze for several secounds.
I search over internet for solution,and i found article that describe how to load file that is a few megs in size using EM_STREAMIN message.
Unfortunatelly,that article is for VB6 and use file for loading while I have to use RTF formatted string.
Does anybody knows how to implement loading string into RTB using EM_STREAMIN message in C#?
|
|
|
|
|
use threads to solve ut problem
|
|
|
|
|
use threads to solve your problem
|
|
|
|
|
Sorry to say but did you think about this reply before posting?
The original poster claims that the RichTextBox itself is freezing.
If you can tell us how to use threads to keep this from happening (don't forget the UIThread has to render the RichTextBox!), you're my hero...
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
Sure, create a new RichTextBox, load it in the background thread, then substitute it
for your existing RTB.
|
|
|
|
|
Yes,that could help,but in that case user must wait until whole string is loaded into new RichTextBox before it is substituted with existing RichTextBox.
Is it possible to load RTF file or string in segments into RichTextBox.
Something similar to MS Word or WordPad
where text is appended in RichTextBox in segments while app remain responsible to user.
I asking that because RichTextBox doesn't have "append" method.
|
|
|
|
|
Hi!
Unfortunately, I don't see an easy solution for you. But if you somehow can split the RTF into smaller parts, you could load them one after the other by using the SelectedRtf property and at least throw in a few Application.DoEvents() so that the RTB updates after each loaded part.
The idea behind this is something like this:
rtb.Clear();
for (int i=0; i<parts.Length; i++)
{
rtb.SelectedRtf = parts[i];
rtb.Select(rtb.Text.Length, 0);
Application.DoEvents();
}
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
the boy is right .. no offence .. but check your premise
|
|
|
|
|
Ok, then please show us a working example. If you don't use a workaround like the one suggested by Luc (which isn't what the poster was asking for and, honestly, I'd rather call cheating :P), I really can't see how this should work.
Sure, "use threads" is the default answer when someone ask for making something more responsive, but in this case it's a Control that can become unresponsive for a longer period of time due to calling one of its methods (or setting one of its properties).
With very few exceptions (and calling LoadFile() or setting Rtf don't belong to them) you cannot safely access a control from another thread than the one it was created on.
So if you create the RTB in another thread (apart from the UIThread), then you'll have to marshal each and every call to this other thread.
But even so: You're calling LoadFile() from the other thread and the RTB is blocking the other thread while the large file is being loaded. During this period of time the RTB doesn't update and thus appears unresponsive.
Out of curiosity I actually tried the "create the RTB in another thread" approach and, apart from proving my point, I also found that even the UIThread seems to be blocked while the RTB is loading a large file in a background thread...
If you're interested, I can post the code here.
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
give me your Email ID i'll mail you solution
|
|
|
|
|
Please use the Email link from one of my postings to send me a PM with your mail adress. I couldn't send you one because CP claims that your mail adress isn't verified.
Thanks in advance, I'd be very interested in a working solution for loading a large RTF string/file into a RTB without blocking it in the process...
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
Boy O Boy... this is not valid excuses.....
i saw your profile might be you are summa cum laude but this time you are not using your wit.
here is no facility provided by CP to send any attachment and writing an artical is a real pain in ass. you can take my ID
think2sameer@yahoo.com
wright70@mailcity.com
i am available on both
|
|
|
|
|
Nobody asked you to send an attachment via CP.
I asked you to send me a personal message with your mail adress so I don't have to write my mail adress here and attact even more spam than I already receive and allow you to do the same.
I'm really sorry if you didn't understand...
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
Hi
I have created a datagridview class that handles keypresses according to our company standerd by inheriting from datagridview.
I now want to open a dialog when the user presses enter. The opendialog function defined in the control is called a desighned. What I am unable to do is overide it from the from that is using the inherited control.
Please can someone give pointers to this regard.
|
|
|
|
|
Think I have solved it.
I have added a member to the control. The variable is of the dialog base class (in this case basedialog that is derived from form.) All my dialogs are derived from this basedialog class.
I create the dialog that is required, set the property and when the enter key is pressed, display the dialog from within the control code. Is this the correct way to do this.
Is there a better way?
|
|
|
|
|
I think, the better way is add event "ShowDialog_XY", which will be raised on [enter] key press and process event in method handled to this event.
The event arguments should contain result of dialog.
For example:
public class MyGrid : DataGridView{
protected virtual void ProcessEnterKeyPress() {
MyGridProcessEventArgs me = new MyGridProcessEventArgs();
this.OnProcessEnterKeyPress( me );
if ( me.Handled == false ) {
}
object result = me.Result;
if ( result == null ) {
}
this.ProcessResultOfEnterKeyPress( result );
}
protected virtual void ProcessResultOfEnterKeyPress( object result ) {
}
protected virtual void OnProcessEnterKeyPress( MyGridProcessEventArgs e ) {
EventHandler handler = this.ProcessEnterKeyPress;
if ( handler != null ) { handler( this, e ); }
}
public event EventHandler<MyGridProcessEventArgs> ProcessEnterKeyPress;
}
public class MyGridProcessEventArgs : EventArgs {
private bool handled;
private object result;
public bool Handled {
get { return this.handled; }
set { this.handled = value; }
}
public bool Result { get { ... } set { ... } }
}
public class Form1 : Form {
...
public Form1() {
this.InitializeComponents();
this.myGrid1.ProcessEnterKeyPress += this.myGrid1_ProcessEnterKeyPress;
}
private void myGrid1_ProcessEnterKeyPress( MyGridProcessEventArgs e ) {
}
}
Geniality is in simplicity.
|
|
|
|
|
Hi Jakub
Im trying to get this code to work so that I can undertand what it is doing. However I get errors compiler when implementing it and do not have suficient understanding to debug it yet.
The error tells me that
public event EventHandler ProcessEnterKeyPress
already exists in the base class
Error 1 The type 'BaseForms.BaseListDialog' already contains a definition for 'ProcessEnterKeyPress' C:\Beeftech\Modules\BaseForms\BaseListDialog.cs 69 35 BaseForms
What do I need to do to fix this.
ProcessEnterKeyPress seams to be defined by the datagridview from which my class inherits.
|
|
|
|
|
I want to get an instance of a running process and thruogh that instance I want to call its members in my application.
Noor
|
|
|
|
|
Play with System.Diagnostics i think you will get from this namespace
<l>Thanks and Regards
Sandeep
|
|
|
|
|
|
You can get the instance of currently running thread through System.Threading.Thread.CurrentThread but i dont think you can call its members a thread may contain several classes, functions etc. So i am not very much optimistic. You can dig deeper into that...
Regards,
Wasif Ehsan.
|
|
|
|
|
Hello!
wrote: I want to get an instance of a running process
using System.Diagnostics;
Your process would be:
Process myprocess = Process.GetCurrentProcess()
Process where you know the name:
Process[] someprocesspername = Process.GetProcessesByName("xxx");
wrote: and thruogh that instance I want to call its members in my application
Don't think this is posible that way!
All the best,
Martin
|
|
|
|
|
I have been researching all day on how to create an FTP site via a website. Our needs for out company is to be able to create FTP sites/virtual directories on the fly as a new team is created. I have some questions.
Most everything I have found works with System.DirectoryServices - which I understand works with Active Directories. Does the server hosting the site have to have Active Directories activated in order to use that dll?
We would prefer not to use Active Directories. Is there another api or method for generating a new FTP site and virtual directory that does not use Active Directories?
Thanks,
CK
|
|
|
|
|
Yes. If you are running Linux, most installations only require you to name a web accessible directory, 'ftp', for it to work as an ftp directory.
Hmmm. Maybe that's just unsatisfactory behavior or something.
|
|
|
|
|
The server hosting our sites is a Windows 2000 box - I appreciate the help you offered.
Our biggest concern is we don't want to use active directories on our web server. We do need to create FTP sites for each team for one of the sites we manage, but to date the only solutions I have seen use System.DirectoryServices and I am uncertain if I have to have active directories turned on in order to make the code work.
Can someone please help me understand how System.DirectoryServices works and if we need to use active directories or not.
If we do, is there another solution that would permit us to create an FTP site on the fly?
CK
|
|
|
|