Set population field validation in masked text box - c#

Hi I am new to C# I have one problem in masked text box
Population range is 1,000 to 12,00,00,00,000
My problem is when enter 1000 in masked text box it will be taken as 1,000 like when i enter 12000 it will considered as 12,000 like default it will arranged in ,.
How can i do it? Please provide if any solution.

What is the Mask property set to? Try making it: #,##0.

Related

convert text box value (12000) to time format (1:20:00) in UWP

I have a project which has simply one text box and some sort of buttons acts as numeric input, This is my question : when I enter a number like 12000 into the text box, it suddenly changes the format to 1:20:00 and display in same text box. can it be handled by Text_changed (event handler)? if yes what is code behind ?

Unique bug in devexpress' combo box, 2 out of 131 rows that were added seemed to have extra characters (WPF)

This is the first time I've experienced something like this. As far as I know I've done everything as they should be and for the most part it did output what I wanted but somehow there were unique bugs that seemed impossible.
It all started with a combo box that I populated with this code:
items.Add(new { Text = dr4["item_name"], Value = dr4["item_id"] });
It did the trick and filled the combo box with the 131 rows of item names in the combo box. But while scrolling inside the combo box, I found two items that were occupying two lines. I don't know how this happened, all of the items that were inserted in that combo box underwent the exact same way since I looped the code above so the problem could have not been from there. I double checked my database to see if I had some extra spaces or characters but they didn't and was normal as the rest of the 129 rows.
I tried creating a textbox and tried to fill it with both the combo box's text and value using this code:
textBox.Text = comboBox.SelectedValue.ToString() + comboBox.Text.ToString();
I had some interesting results. The 129 rows of data appeared right next to each other (not even a space) BUT the 2 specific rows of data appeared as if someone pressed enter after the selected value was printed.
For the sake of further explanation, let's say the selected value was "5" and the text was "This is number 5":
Now, the textbox's text output from the 129 rows were:
5This is number 5
While the textbox's text output from the 2 other rows where:
5
This is number 5
Now I don't know how this is happening and can't even explain it myself as they're both all from the same table, it couldn't be their length because there are longer texts from the other text from the 129 rows than the 2 other rows that's behaving unexpectedly.
I can't understand where are they getting this extra characters from, there doesn't seem to be any pattern. I think this has something to do with the devexpress combo box I'm using. I've tried populating a normal visual studio's combo box and it produced my desired output, all of the 131 items inside the combo box were normal.

Editing values by replacing them

I want to replace my values in text box without deleting them, for example, I output in my text box time "HH:mm:ss" and if I type in that textbox first number I would like to change "H" on it, and so on. How can i do that?
I don't ask code, just an advice.

Issue with textbox rounding a number

I have the following code:
txtbox1.Text = listView1.SelectedItems[0].SubItems[11].Text;
The value of the selected item of the listview is "33,5" but when the code reachs this line, in the textbox writes 34,00.
I don't know why if there's a text inside a text, I have tried convertingo to decimal before asing to the textbox but still put 34,00. I've tried too puting 33.5 instead of 33,5 but then the code writes in the textbox: 3350,0.
What can I do?
Thanks
try this:
string number = listView1.SelectedItems[0].SubItems[11].Text;
and check in debug mode what number contains.
I am convinced you have the right value in there, a simple string, but the txtbox1 is applying certain formatting on text change. You should find this out and fix the way content of txtbox1 is formatted after assignment.

Limit number of characters in Label

I am using label in my winform . It displays the value which I enter in another textbox. My problem is label does not display whole characters I enter in textbox. Label's size is width=160 and height=19. So it truncates the last value. For testing purpose when I enter "W" in caps in textbox ;label can display maximum 13 "W"s. So I am trimming the
charater's by using labelname.substring(0,10); and for next three characters I am appending 3 dots(...)
But this solution is not desirable to my senior. He is telling me that if I enter all small letters "l" in textbox then though label has space to display more than 13 characters it will display only 13 characters(including dots).
Does anybody has solution on that ?? I also cannot increase width or height of label to accomodate more characters.
Well, you could set the AutoEllipsis property to true and don't worry about the length of the text.
Edited to Add: as per comments
If you're using RadLabel from Telerik then you need to dig a little more:
RadLabel.LabelElement.LabelText.AutoEllipsis
Nothing that 5 minutes looking through the documentation doens't solve
Set the AutoEllipsis property of your Label control to true. You can do this either in the designer, or through code:
myLabel.AutoEllipsis = true;
That will cause the ellipsis character (...) to be automatically appended to the text if it overflows the space available in the label. You won't have to manage this yourself in code at all.
This property is available as far back as .NET 3.0.
If I understand your question correctly, you can use Textbox.MaxLength property which only allows the user to enter the maximum number of characters you set the value to.
You can set the label's AutoEllipsis property to true and let it figure this out for itself.
Gets or sets a value indicating
whether the ellipsis character (...)
appears at the right edge of the
Label, denoting that the Label text
extends beyond the specified length of
the Label.

Categories