|
Hi,
you dont need a separate thread to show a progress bar.
you could call Application.DoEvents() every time you update the progress, but I do not
recommend that, it is a hack/ugly/not descent/whatever.
You would be better of using another thread to do the lengthy calculation,
and let the main thread (aka GUI thread) show the progress bar; to get it on top,
make it a form owned by your main form.
To communicate from your lengthy calculation thread towards the progress bar, you would
need Control.Invoke if that thread holds the update-progress initiative. I often do it
the other way around: have a Forms.Timer periodically interrogate the calculating thread
about its progress (e.g. use a property of your job object) and update the progress bar.
|
|
|
|
|
|
Hm, this class is Framework 3.0 specific.
|
|
|
|
|
Nope, it was added in .NET 2.0.
|
|
|
|
|
OK, still too new
|
|
|
|
|
My question is based on functionality in Masked Textbox control which is available only in .Net framework 2.0 onwards. I want the kind of functionality provided by MaskedTextbox control but I can't use this control as I'm currently working on framework 1.1.
So I have decided to make one for me on my own. I derived the control from Text box. I was able to implement Mask dialog and validations but stuck up with text property implementation of control.
For the Masked Textbox, if you implement telephone no. mask with format (___)___-____, then text property value initially will be blank. But on the form, Masked TextBox text will show format i.e. "(___)___-____". Also, if I write 333 in property grid for text property then in property Grid I will be able to see value as "333" while in the Control on the form it will display me a text like "(333)___-____". So in a way two different values for the same text property in property grid and control. So this is bit confusing and don't know how to implement this thing in a same way as provided by Masked Text box.
I tried to implement this by overriding the text property and giving different implementation for design time and run time. But its not helping me.
Can anyone help me by providing some ideas on how to do above things. I hope I'm clear with my question. If reading above, you are not clear about the question pls write back to me or check the working of Masked Textbox control for better understanding.
Regards,
KC
|
|
|
|
|
Hello,
I think in that case only a workaround does the trick!
Because Text property of TextBox seems to be special case.
Therefore I would use an additional "newText" property and hide the "Text" property.
private string _newText="";
[DefaultValue("")]
public string NewText
{
get
{
return _newText;
}
set
{
if(value!=_newText)
{
_newText = value;
Text = _newText+" I'm formated";
}
}
}
[Browsable(false)]
public new string Text
{
get
{
return base.Text;
}
set
{
if(value!=base.Text)
{
base.Text = value;
}
}
}
Hope it helps!
All the best,
Martin
|
|
|
|
|
Hi,
I'm starting to read up on serializing my classes using XML, seems really useful but depending on which article I read opinions vary on whether ArrayLists can be serialized. Does anyone know for sure whether they can or can not? It seems as though it changed from 1.1 to 2.0, but I cant tell for sure.
Thanks
|
|
|
|
|
It has changed from .NET 1.1 to .NET 2.0, as far as I know you can serialize List<T> in .NET 2.0
Another method is the mark the list with the [XmlElement] attribute, to make sure it gets serialized correctly.
WM.
What about weapons of mass-construction?
"What? Its an Apple MacBook Pro. They are sexy!" - Paul Watson
My blog
|
|
|
|
|
Hi,
i am developing a text editor for windows forms in c#. i would like to know how to add bullets and numbering. I have added the following code.
<br />
rtbDoc.BulletIndent = 10;<br />
rtbDoc.SelectionBullet = true;<br />
but it gives only 1 type(circle) of bullets. But i have to show square type bullets and numbering...
will you please give some guidelines...
Thanks in adavnce
Sebastian
|
|
|
|
|
Sebastian T Xavier wrote: i am developing a text editor for windows forms in c#.
Looks to me as if you are just using the RichTextBox. That isn't "developing a text editor". Someone else has already developed it, you are just putting it in a form.
Sebastian T Xavier wrote: but it gives only 1 type(circle) of bullets. But i have to show square type bullets and numbering...
will you please give some guidelines...
If you were genuinely "developing a text editor" you would be able to do what ever you wanted. So, actually do what you say you are doing.
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
"I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless."
Ready to Give up - Your help will be much appreciated.
My website
|
|
|
|
|
AFAIK there is only one bullet style in RTB.
|
|
|
|
|
|
Hi!
The RichTextBox actually can do a lot more than you can access with the built-in methods and properties.
Underneath the .NET wrapper there's a RichEdit control (version 2) you can send windows messages to (read about rich edit control messages in MSDN) to achieve several nice effects like different kinds of numbering, underline styles, superscript/subscript and several others.
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
Hello all,
I'm very frustrated with a bug that I can't seem to beat. I'm using Activator.CreateInstance to create an array of objects based on a sampleObject. Each instance of SampleObject contains a uniqueid which is generated randomly in the constructor. Something like this:
<br />
SampleObject sampleObject = new SampleObject();<br />
SampleObject[] array;<br />
<br />
<cut other stuff><br />
for (int i = 0; i < numberToCreate;i ++)<br />
array[i] = Activator.CreateInstance(sampleObject.GetType());<br />
<br />
<cut rest of code><br />
Now, when I run this in the VS debugger it works fine and I get a proper batch of unique objects. However, when I run the code outside of VS, all the objects have the same uniqueid!
Anyone out there have any idea what is going wrong or more importantly how to fix it
TIA
|
|
|
|
|
I tried something like this, and it worked perfectly. My thoughts:
1. Are you sure you're running the same code outside of VS? Maybe what you're running from outside is an older build.
2. You haven't shown us the ctor logic. When the ID is generated in the constructor, try printing it or logging it to a file, for debugging purposes.
3. Aggressive compiler optimization settings may be interfering with your program logic. Try running it without optimizations.
Cheers,
Vıkram.
After all is said and done, much is said and little is done.
|
|
|
|
|
Hello Vikram,
Thanks for responding. I have verified that I am not running the latest build, etc. I also tried with optimisation disabled.
Here is my Constructor:
public class MyDerivedObject : MyBaseObject
{
public static int NUMBER_OF_DIMENSIONS = 2;
double uniqueID;
public MyDerivedObject() : base(NUMBER_OF_DIMENSIONS)
{
uniqueID = base.RandomGenerator.NextDouble(); // generate uniqueID
Console.WriteLine("uiqueID: " + uniqueID.ToString());
}
}
Thanks again
|
|
|
|
|
Just a hunch, but the problem could be with RandomGenerator. Maybe you're making the same mistake as I was here[^]
Did you try the logging part? Another angle for you: just for debugging, insert a
Thread.Sleep(500); as the last line of your MyDerivedObject's constructor.
Cheers,
Vıkram.
After all is said and done, much is said and little is done.
|
|
|
|
|
Thank you Vikram! I'm not sure WHY it fixed the problem, but making the RandomGenerator static as suggested in the link you provided did the trick!
Many many thanks to you!
|
|
|
|
|
s0ren wrote: I'm not sure WHY it fixed the problem
That way, it only gets initialized once. If you create a random number generator inside the method, it is likely that the execution is so fast it gets seeded with the same value and generates the same 'random' numbers.
s0ren wrote: Many many thanks to you!
You're welcome; I'm glad I could help somebody.
Cheers,
Vıkram.
After all is said and done, much is said and little is done.
|
|
|
|
|
Hello everyone!
I need to store such data:
Partitions(ex: english), Authors(ex: Shakespeare), Books(ex:Otello).
Ierarchy is Partitions->Authors->Books.
What is the best way to store data ?
I used a ArrayList -> SortedList -> SortedList and serialization.
I don't want to use SQL, because it cannot be installed on each computer, where this program will be used.
One nation - underground
|
|
|
|
|
For storing it, I would recommend XML. For displaying it, you can go for a TreeView.
Cheers,
Vıkram.
After all is said and done, much is said and little is done.
|
|
|
|
|
Do you mean XML, you mean serialization ? What kind of structure should i use?
Is isn't it wery expensive to use a->s->s->? The number of elements won't exceed 1000.
One nation - underground
|
|
|
|
|
Dude, I thought your data looked something like this
English
Twain
Tom Sawyer
Huck Finn
Orczy
The Scarlet Pimpernel
Dawkins
The God Delusion
The Selfish Gene
Hindi
Premchand
Panch Parmeshwar XML is the best way to store this.
<yourRootTag>
<language name="English">
<author name="Twain">
<title>Tom Sawyer</title>
<title>Huck Finn</title>
</author>
Other authors go here...
</language>
Other languages go here...
</yourRootTag>
Cheers,
Vıkram.
After all is said and done, much is said and little is done.
|
|
|
|
|
Thanks for help. Can You tell me where can i read about this way of xml ? Read all Xml related articles ?
One nation - underground
|
|
|
|