|
Hello everyone,
Well I’m working in a C#2.0 desktop application and I’m using numericupDown Objects to take numeric input. The only problem I’m having is that it can take more than one decimal points and I want to some how stop that thing from happening, like the control should not accept a decimal point when it already has one. So can u plz help me in this?
Thanks in advance,
Rocky
|
|
|
|
|
You can try the following:
- Create a new component, which inherits System.Windows.Forms.NumericUpDown .
- In your new component override the OnTextBoxKeyDown() method, and inside it put code like this:
protected override void OnTextBoxKeyDown(object source, KeyEventArgs e)
{
if (e.KeyCode != Key.Decimal || !Text.Contains("."))
base.OnTextBoxKeyDown(sender, e);
} This should disable calls to base.OnTextBoxKeyDown() when the user presses the decimal key, and a decimal point is already present.
Regards,
Shy.
|
|
|
|
|
hi,
the code provided by Shy will prevent the user from entering more than one decimal if and only if the user uses the key board to enter the data. what if one chooses to copy paste the data??
to handle this you need to override the event handler for ValueChanged and check for the decimal character.
regards
|
|
|
|
|
thats a very good point u know... thanks
|
|
|
|
|
1119 wrote: the code provided by Shy will prevent the user from entering more than one decimal if and only if the user uses the key board to enter the data. what if one chooses to copy paste the data??
You're right... I didn't think about it...
1119 wrote: to handle this you need to override the event handler for ValueChanged and check for the decimal character.
Wouldn't that cause flickering text?
That is, If a second decimal point is now present, and through ValueChanged you set the Text property to remove it.
The text would be drawn once before your code executes, and once after.
|
|
|
|
|
shyagam wrote: Wouldn't that cause flickering text?
no, i don't think so. it will be fired only after the value is changed, just like the keypress event handler is fired for every key pressed. and if keypress event handler doesn't cause flickering, i don't see any reason why this should?
if you implement this, you don't need the keypress event handler and it will provide the same function.
there may be other ways to implement this as well.
regards
|
|
|
|
|
That looks very helpful indeed thanks alot brother
Rocky
|
|
|
|
|
shyagam wrote: if (e.KeyCode != Key.Decimal || !Text.Contains("."))
base.OnTextBoxKeyDown(sender, e);
Can u plz tell me where this Text is Comming from... (!Text.Contains("."))
???
|
|
|
|
|
It was inherited from the NumericUpDown class.
It's the same if you would write "this.Text ", but the "this " keyword is redundent here.
Shy.
|
|
|
|
|
oh Sorry I was confused bcz I wasnt showing in the designer and neither it was available to Intellisense So i thougt it wasnt there at all.
|
|
|
|
|
can that copy paste issue be resolved in the same manner?
|
|
|
|
|
how can i display all the drive and files in the tree view control.
Jayesh Talsaniya
|
|
|
|
|
This article[^] might help.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
In my app (using WPF) I have a side bar displaying a bunch of option.
I display the option with a list box and some databinding on the selected item.
now it's a sidebar, and when there are a lot of item, the scroll bar on the side is ugly, I would like to replace it with someting like that[^].
i.e. instead of having a scrollbar on the right, I want to have up and down arrow at the top and bottom.
Any suggestion on how to achieve that?
is there an object more appropriate that a list box?
Any XAML code example welcome!
|
|
|
|
|
Hello everyone,
First of all let me take this opportunity and thank you all guys for helping out.
I was wondering if it is possible to have a TabControl without the Tab avaliable for clicking and changing the page. I know I might sounded from lala-land when I said a TabControl without the Tab to change page, but I am plaing to change the page programitically. )
I have come across this article which any way does what I am looking for.
http://www.codeproject.com/useritems/WizardFromTabs.asp[^]
But I was wondering if there is any better way to have this done. To be honest with you, I don't fancy using a Panel to hide the Tab of the TabControl in order to stop the user from clicking on it.
Thank you very much and have a great day.
Khoramdin
|
|
|
|
|
Hello,
So do you whant to hide the Tab, or do you just whant to prevent the changing of the Tab?
All the best,
Martin
|
|
|
|
|
Hello Martin,
Thanx for the reply. Well, I wish to hide them and take the privilage of clicking the tab away from the user.
As you might have noticed, I am trying to have multi-pages which are accessed programitically rather by clicking the Tab.
Thank you very much and have a great day.
Khoramdin
|
|
|
|
|
Hello,
It sounds like you whant to disable nearly all features of the TabControl, because you don't need them.
I would recomment you to build your own UserControl which hold an Collection of UserControls (like TabPages property of TabControl class), and add an your own Page switch loggig to the class.
If you whant to stay with the TabControl, you could inherit the a class from TabControl and ovveride the OnDrawItem method and play around a little with that.
protected override void OnDrawItem(DrawItemEventArgs e)
{
//do some fancy stuff
base.OnDrawItem(e);
}
I'm looking for some more suggestions.
Hope it helps!
All the best,
Martin
|
|
|
|
|
Hi,
Presently I am working on Setup and deployment project. I am using Visual Studio 2005.
The problem is, I need to add some .msi packages to the setup project.
How can this adding packages be done?????
Thanks in advance
regards,
Naresh Nelluru.
|
|
|
|
|
From menu bar select Action - Add - File
Regards,
Sylvester G
sylvester_g_m@yahoo.com
|
|
|
|
|
Thanks Sylvester,
But my problem is that I already had an msi package(which is an installer) and i want to
add that one to my setup and deployment project. When I want to install my setup project the msi package also should be installed so that i don't have to install that msi package once again by cliking on it. I added the msi package(installs when we click on it), but my project is copying that package and placing it in the specified location. Once again i have to do double clicking on that package to install it.
Is there any way to remove the last step (Once again i have to double click that package to install it).
regards,
Naresh Nelluru
|
|
|
|
|
When I run my outlook addin I get an exception with the following exception:
'An unhandled exception occurred in your application. Contact your administrator or the author of this document for futher assistance.'
Can anyone please help me determine what is causing the exception.
Mvelo Walaza
Jnr Developer
Telkom SA
|
|
|
|
|
Hai everybody,
What is the purpose of tag in the controls?
I am having a tree view in that i am listing the products by means of a product name and while clicking on it i have to edit the product, for that i require product id but it should be hidden in the tree view can i use the tag to store this.
Please give me a solution.
Best Regards,
M. J. Jaya Chitra
|
|
|
|
|
The Tag is a free place where to store user data. You can do whatever you want with it.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
I'd often store values from an enum, that relate to selections being made, etc.
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 )
|
|
|
|