|
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
|
|
|
|
|
I am trying to learn C# in a classroom setting. I have hit a barrier in trying to understand something.
In the following code sample under where it says weeklySalesAmount I get the message "The name 'weeklySalesAmount' does not exist in the current context". And under the mutators section where it says SetGrossPay it tells me "'Exercise_9_Chapter_4.Deduction.SetGrossPay(double)': not all code paths return a value"
public Deduction(string empName, double weeklySales)<br />
{<br />
name = empName;<br />
weeklySalesAmount = weeklySales;<br />
}<br />
<br />
public double SetGrossPay(double weeklySales)<br />
{<br />
const double GROSS_WEEKLY_PAY = .07;<br />
grossPay = weeklySales * GROSS_WEEKLY_PAY;<br />
}
In the next section where it says .netPay I'm told that "'Exercise_9_Chapter_4.Deduction.netPay' is inaccessible due to its protection level ",and that SetNetPay is "The name 'SetNetPay' does not exist in the current context".
Deduction employee = new Deduction(empName, wkSales);<br />
employee.netPay = SetNetPay();
I thought that I had everything done correctly according to the book. I have no idea as how to correct these problems. If anyone can help me, or at least steer me in the right direction, it would be muchly appreciated. Thank you.
-- modified at 17:04 Monday 26th February, 2007
|
|
|
|
|
Don't post programming questions in the lounge. I moved it for you.
JMOdom wrote: "'Exercise_9_Chapter_4.Deduction.SetGrossPay(double)': not all code paths return a value"
In fact, none of them return a value. That's what the message is telling you. You wrote a function that returns double, and you didn't return anything. Add return grossPage; at the end of the function and it will work. Also, if you have const values, it's a good idea to put them at the top, the whole point is that you can easily change them. Putting them in the function, you may as well hard code the value.
JMOdom wrote: 'Exercise_9_Chapter_4.Deduction.netPay' is inaccessible due to its protection level",
This means that netPay is private or protected. You should use public properties to expose private or protected members. You should expose only a get method if at all possible. Oh - if you didn't put an access modifier, it's private by default. What I mean is:
int n;
is private.
public int n;
is public, but you should instead do this:
private int _n;
public int N {
{
get { return _n; }
// set { _n = value; }
}
and only uncomment/add the set if you have to.
JMOdom wrote: and that SetNetPay is "The name 'SetNetPay' does not exist in the current context".
You've not shown us any code which involves a method called SetNetPay, so I can only assume this error is correct ( the method does not exist )
JMOdom wrote: I have no idea as how to correct these problems
I'm happy to help, but in each case, the compiler has told you what is wrong. As I help you through these issues, take note of what the terminology is, so you can learn how to use the error messages to work out how to fix your code
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
JMOdom wrote: "The name 'weeklySalesAmount' does not exist in the current context"
JMOdom wrote: public Deduction(string empName, double weeklySales)
{
name = empName;
weeklySalesAmount = weeklySales;
}
You need to declare variable "weeklySalesAmount". Probably at same place as variable "name".
JMOdom wrote: 'Exercise_9_Chapter_4.Deduction.SetGrossPay(double)': not all code paths return a value"
JMOdom wrote: public double SetGrossPay(double weeklySales)
{
const double GROSS_WEEKLY_PAY = .07;
grossPay = weeklySales * GROSS_WEEKLY_PAY;
}
And that is correct, SetGrossPay has return type of double, you should have return grossPay; before closing bracket. Or better, change return type from double to <c>void.
It sucks if examples in your book don't even compile. Not that surprising tho.
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus
|
|
|
|
|
Thanks for the answers folks. Sorry I got into the area. All I can say is that I'm very new at this.
The answers given have helped greatly. Thanks again.
|
|
|
|
|
When I derive a generic collection from another custom generic class, the signature is creating a lot of problems for me.
English:
Build a GenColl (derived from keyedCollection ) containing elements of a GenElement.
- The compiler tells me to use an identifier in the signature and not the type?!?!
- and when I use place holder for types, it asks for reference namespace??
_______________________________________________________
The actual generic classes (simplified for easy reading)
// simple - works, the element or base construct
public class GenElement<Key, Value>{}
// this doesnt work, it is a collection of the above generic class
// I am not sure of what the signature should be... tried many combo
public class GenCollection <Guid, GenElement<<Key, Value>> : KeyedCollection<Guid, <Key, Value>>
{
// rest of the implementation blah blah
// with abstract over rides
}
^ ^
-The problem is, if I include the type place holders Key, Value in the
definition (public class GenCollection <Guid, GenElement<<Key, Value>> ), the complier complains that GenElement should be an identifier and not a type? if I removed the type place holders (public class GenCollection <Guid, GenElement>) its just fine, but doesnt see that GenCollection contains a GenElement
-can some help me resolve this. What should I do to get a generic collection GenCollection container that contains genElement (which further has two typePlace holders, key and value GenElement<<Key, Value>)?
-How do I, in the definition tie the Guid to the Key, is it possible?
-- modified at 10:28 Tuesday 27th February, 2007
|
|
|
|
|
Can you post it with the HTML tags turned off because all the < and > signs are garbled.
Perhaps what you want is (complete guess here because the code isn't visible):
public class GenElement<TKey, TValue> : KeyedCollection<TKey, TValue>
{
}
|
|
|
|
|
I turned off the HTML tags but how do I get the yellow?
|
|
|
|