|
progressBar1.RightToLeftLayout = true;
progressBar1.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
EDIT...
Missread
set the style property to Marquee
|
|
|
|
|
Hi, I would like to know how to convert a double to string.
Example:
double = 3,456,789.30
string equivalent = three million four hundred fifty-six thousand and seven hundred eighty-nine & 30/100
Thanks a lot! I really need this.
|
|
|
|
|
Theres no built in soltuion for this in C# or the .Net Framework, but google[^] has lots of results.
|
|
|
|
|
digitNames = new string[] { "", "one", "two" ... };
tensDigitNames = new string[] { "", "ten-", "twenty-", "thirty-" ... };
magnitudeNames = new string[] { "", " thousand", " million" ... };
1. Initialize a string called "result" to the fractional part preceded with an "&"
2. Initialize an integer array called "number" of the digits of the number, from LSD to MSD
(in your example, {9, 8, 7, ... 3})
3. Iterate through the digits in "number" to get the variables "curDigit" and "curDigitIdx"
4. Perform the following logic using curDigitIdx (the index in your array) and curDigit
switch (curDigitIdx % 3) {
case 0:
result = string.Format("{0}{1} {2}", digitNames[curDigit],
magnitudeNames[curDigitIdx / 3], result);
break;
case 1:
result = string.Format("{0}{1}", tensDigitNames[curDigit], result);
break;
case 2:
result = string.Format("{0} hundred {1}", digitNames[curDigit], result);
break;
} Note that the preceding code is simply a starting point, and that the formatting will require a number of special cases (such as getting 11 to be printed as "eleven" as opposed to "ten-one" and 50 being printed as "fifty" instead of "fifty-". Hope this helps,
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
|
|
How to Display Moving messages in Internet Explorer(browser) Status Bar using C# Code?
|
|
|
|
|
Outside of Silverlight you can't use C# code to affect the IE message bar. You have to use JavaScript (or VBScript if you're feeling really perverse).
|
|
|
|
|
ok.
Can u please tell me the code in javascript ,and how to do this?
|
|
|
|
|
Hi,
you can perform a browser's "View Source" on any web page that does what you want,
and look at the code they use to do it...
|
|
|
|
|
|
Hi!
I've got a string:
string str = ">200 <=250";
and a regular expression:
Regex rx = new Regex ("^(>=?|<=?|=) *[0-9]+ *$");
the way I see it (understand regex) with
rx.Matches(str);
I should get two matches (">200" and "<=250")
but I get an empty collection..
did I do something wrong?
thanks for any help!!
Seishin
life is study!!!
|
|
|
|
|
You probably want this:
Regex rx = new Regex ("(>=|<=|=)\d+");
x.Matches(str);
This matches all numbers with a ">", ">=", "<=" before it, no matter where in the text it is. It also matches in-text, it would for example also match "thisisatext>=500", which you could exclude by adding "\b"'s for word-end-checking, like this:
Regex rx = new Regex ("\b(>=|<=|=)\d+\b");
|
|
|
|
|
thanks..
"(>=?|<=?|=) *\d+"
works fine.. i wanted to match '>' '<' as well so i had to add '?' after '='.
life is study!!!
|
|
|
|
|
Two things:
1. You are REQUIRING your match to occur for the entire string since you are using '^' and '$' at the beginning and end, respectively, and
2. You may need to escape the '>' and '<' characters.
Implementing both of the above, your regex becomes...
Regex rx = new Regex(@"(\>=?|\<=?|=)\s*\d+\s*"); Let me know if this works as desired,
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
yaeh. the problem was with ^ and $.. removing them solved the issue..
thanks!
life is study!!!
|
|
|
|
|
Hi guys,
I have a problem regarding threads in my application. I got a Form in my app which owns a class derived from WarnModule (see http://pastebin.com/m72a3f841[^]) that periodically triggers some kind of warning (i got different implementations of that). The problem is that the finalizer of the WarnModule does not get called when the application that owns the WarnModule-derived class wants to exit and the still running thread in WarnModule then blocks the application from exiting.
How can i solve this issue?
Thanks in advance,
Lucas
|
|
|
|
|
You will need to some how signal the thread that it is time to exit. One way to do this (logically, but I leave coding it up to you) is as follows...
1. Create a shared boolean object initialized to false called "TimeToExit"
2. Periodically check the value of TimeToExit from the running thread. If true, exit.
3. From the main thread, after setting TimeToExit to "True" and waiting for some amount
of time without the thread ending (the maximum thread response time), kill the thread :( Note that you will NOT need to make the boolean thread safe, as one thread is reading and the other is writing, and no inconsistent state can occur here. Hope this helps,
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
That's what i am already doing, but I dont know where to set that flag from. The ApplicationExit event does not get fired until the object has been disposed, which never happens because the Thread keeps running.
|
|
|
|
|
What event triggers you wanting to exit the application? Form.Closing? Somewhere in your code there will be SOME event (that I can't guess) which is triggering this desire to exit. If it is user initiated, then there must be some event like Form.KeyPress, Button.Click, Form.Closing, etc. If it is initiated by code somewhere, then just add that line to set the bool at that point. If you still cannot figure out where to put the code for this, explain what event is triggering the application exit and I can try to help some more.
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
I can signal the Thread to exit after Application.Run() returned, so that solves my problem.
But what I really wanted to do was to make the object clean up it's own mess (as you are supposed to do it in OOP), but I didn't succeed in that.
I tried stopping the Thread in the Finalizer and in Dispose() (i derived the class from IDisposable), neither worked.
|
|
|
|
|
Hi all,
I am using the Find method if the RichTextBox to search for a certain word within the control. But how can I move to the line where the text was found ??
int indexToText = richTextBox1.Find(text, RichTextBoxFinds.MatchCase);
if(indexToText >= 0)
{
}
Many Thanks
Regards,
The only programmers that are better that C programmers are those who code in 1's and 0's
Programm3r
My Blog: ^_^
|
|
|
|
|
Can't you just do the following?
int indexToText = rtb.Find(text, RichTextBoxFinds.MatchCase);
if(indexToText >= 0) {
rtb.Select(indexToText, 0);
rtb.ScrollToCaret();
} Hope this helps,
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
Hi,
Thanks for the response, but when I try and search for the next word that matches the find it keeps repeating the same line within the RichTextBox. What am I doing wrong?
This is the code I'm trying...
if (this.activeRichEdit.Find(textBox1.Text, 0, activeRichEdit.Text.Length, options) != -1)
{
int endIndex = this.activeRichEdit.Text.Length;
int findIndex = this.activeRichEdit.Find(textBox1.Text, 0, endIndex, options);
this.activeRichEdit.SelectionColor = System.Drawing.Color.DarkRed;
activeRichEdit.Select(findIndex, 0);
activeRichEdit.ScrollToCaret();
}
The only programmers that are better that C programmers are those who code in 1's and 0's
Programm3r
My Blog: ^_^
|
|
|
|
|
int foundIdx = 0;
while ((foundIdx = rtb.Find(textBox1.Text, foundIdx, rtb.TextLength, options)) >= 0) {
rtb.Select(foundIdx, textBox1.TextLength);
rtb.SelectionColor = System.Drawing.Color.DarkRed;
foundIdx += textBox1.TextLength;
}
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|