|
|
It might not help him because it runs once a week and exits after running.
Vasudevan Deepak Kumar
Personal Homepage Tech Gossips
The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep!
|
|
|
|
|
Have you asked yourself in the currency format function TextChange how my example below the cursor does not focus on the No. 2 spot, the book help me thanks!
if (textBox1.Text == "")
return;
else
{
int iIndex = textBox1.Text.IndexOf('.');
if (iIndex == -1)
{
}
else
{
string strT = textBox1.Text.Substring(iIndex + 1, 1);
if (textBox1.Text != "")
{
}
}
double a = double.Parse(textBox1.Text.Trim(','));
textBox1.Text = a.ToString("#,###");
}
modified 8-Mar-12 22:18pm.
|
|
|
|
|
Sorry, but that doesn't make much sense.
When you post code, please use the code widget above the textbox - it preserves formatting which makes the whole thing more readable.
I have reformatted your code, and also refactored it to make it more readable - taking out redundant conditions and so forth:
if (textBox1.Text != "")
{
int iIndex = textBox1.Text.IndexOf('.');
if (iIndex != -1)
{
string strT = textBox1.Text.Substring(iIndex + 1, 1);
}
double a = double.Parse(textBox1.Text.Trim(','));
textBox1.Text = a.ToString("#,###");
}
The trouble is that I have no idea what you are trying to do, so I also have no idea what problem you are trying to get help with!
Please try to explain a bit better so we can help you.
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
We now want to enter the number into the textbox, textbox itself decimal format and displays the time on that textbox. For example, enter "123456789", the textbox will appear as 123,456,789. I have a problem when entering a string from 1 to 9 are ok, but when inserting a number in the range from 1 to 9, the textbox back to position the cursor on the first position, thanks to your help with , thank you very much.
Code I wrote
private void textBox1_TextChanged(object sender, EventArgs e)
{
try
{
if (textBox1.Text != "")
{
int iIndex = textBox1.Text.IndexOf('.');
if (iIndex != -1)
{
string strT = textBox1.Text.Substring(iIndex + 1, 1);
}
double a = double.Parse(textBox1.Text.Trim(','));
if (textBox1.SelectionStart >= textBox1.Text.Length)
{
textBox1.Text = a.ToString("#,###");
textBox1.SelectionStart = textBox1.Text.Length;
}
else
{
textBox1.Text = a.ToString("#,###");
}
}
}
catch (Exception) { MessageBox.Show("Must enter the number ."); }
}
modified 9-Mar-12 7:18am.
|
|
|
|
|
Do not use the TextChanged event, LostFocus or Validating are better.
|
|
|
|
|
I think there are workarounds, but they have not thought out.
|
|
|
|
|
Thanks for your interest in my question the last few days, now I have done the above issue then.
|
|
|
|
|
Not sure what you want to do. Perhaps:
int amount;
if (int.TryParse(textBox1.Text, out amount))
{
textBox1.Text=amount.ToString("#,###");
}
|
|
|
|
|
Mightn't a NumericUpDown be what you want?
|
|
|
|
|
Have you no one has any solution to make stars?
|
|
|
|
|
This big forum who can solve the problem of your own?
|
|
|
|
|
Good evening, I want to test if the list of addresses in a gride view is valid or not,I want to insert a new colum I inserted an image or how could I do?
for(i=0;i<=j;i++)
{
adress(dgv1.SelectedCells[i].ToString());
if (vadrs.validate(adress))
{
!!!
}
else
{
!!!
}
{</pre></pre>
|
|
|
|
|
First, why does everyone treat the datagrid as if it's Excel??
Wouldn't you just bind the datagrid to a collection of address objects? Wouldn't one of the properties of a address object (for whatever type of address you're talking about) be IsValid and return a True/False value?
Then it should just be a simple matter of using a TemplateField on this "column" and returning the URL for either a good address or another for a bad address.
No, I don't have examples as I don't really do any ASP.NET stuff.
|
|
|
|
|
The bigger problem is the original thread is also a breed of 'code solicitation', which is not normally supported in these forums.
Vasudevan Deepak Kumar
Personal Homepage Tech Gossips
The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep!
|
|
|
|
|
|
I would choose IsEmpty because IMHO it implies a predicate that checks for emptiness, while Empty implies either a method to empty the polygon or a singleton instance of an empty polygon.
/ravi
|
|
|
|
|
|
Hmmmm... from the existentialism point of view, isn't a polygon with no points null??
Seriously, IsEmpty could also be used to describe the polygon as an enclosure. So, IsEmpty could actually refer to the polygon enclosing some content.
And is a polygon with only one or two points really a polgyon? Wouldn't the property then become IsValidPolygon?
Just some food for thought...
|
|
|
|
|
.NET isn't entirely consistent on the matter. Have a look at all the boolean properties of a System.Windows.Forms.Form, including:
1. Visible
2. IsAccessible, IsDisposed, IsMdiChild, ...
3. AllowDrop, CanFocus, CanRaiseEvents, CanSelect, ...
4. AutoScroll, AutoSize, ...
5. Created, Enabled, ...
Except for #1, they all have a verb (or even two), and that is how I'd do it too. One should avoid confusion, especially when the word could be an adjective as well as a verb. So I would reserve Empty for an action (method or event), IsEmpty for a property.
|
|
|
|
|
We can take this thread over and discuss such issues.
On something I was writing last week I have a Parse method and decided to have a TryParse as well, but it occurred to me that there is no need to differentiate the method names -- having overloaded Parse methods won't cause any trouble. So I wonder why Microsoft decided to use a new name. I suspect it's simply a matter of marketing -- they can advertise and talk up the new TryParse methods more easily that way.
|
|
|
|
|
I guess it would be considered too confusing to have some Parse() methods that throw exceptions on failure, and others that just return false; I do recall a Microsoft recommendation NOT to have a parameter that controls whether failures would throw exceptions, for the same reason.
|
|
|
|
|
Luc Pattyn wrote: it would be considered too confusing
I disagree; the boolean return and the documentation make it clear.
|
|
|
|
|
bool.Parse() would always return a bool...
|
|
|
|
|
True, but then there's the out parameter.
|
|
|
|