Sign in to follow this  

[.net] Changing position when typing in decimal box

Recommended Posts

I'm not sure how I can approach this, what I'm trying to do is have it so the user can type in some numeric fields and it will take those values when the box is changed and update the data structures like so...
private: System::Void frameUpDown_KeyUp(System::Object * sender, System::Windows::Forms::KeyEventArgs * e) { frameUpDown_ValueChanged(sender, NULL); }

private: System::Void frameUpDown_ValueChanged(System::Object *  sender, System::EventArgs *  e)
			 System::Windows::Forms::TreeNode* sn = FrameLayout->SelectedNode;

			 // only check if these items are a frame, not an animation
			 if(sn != NULL && sn->Parent != NULL){
				 LSFW_FRAMEINFO* fi = __try_cast<LSFW_FRAMEINFO*>(sn->Tag);

				 // check each button and set the value, or request a set using dialogs
				 if(sender == frameUpDown1) fi->position[0] = (float)frameUpDown1->get_Value();
				 else if(sender == frameUpDown2) fi->position[1] = (float)frameUpDown2->get_Value();

				 else if(sender == frameUpDown3) fi->centre[0] = (float)frameUpDown3->get_Value();
				 else if(sender == frameUpDown4) fi->centre[1] = (float)frameUpDown4->get_Value();

				 else if(sender == frameUpDown5) fi->scale[0] = (float)frameUpDown5->get_Value();
				 else if(sender == frameUpDown6) fi->scale[1] = (float)frameUpDown6->get_Value();

				 else if(sender == frameUpDown7) fi->rotation = (float)frameUpDown7->get_Value();
				 else if(sender == frameUpDown8) fi->duration = (DWORD)(float)frameUpDown8->get_Value();
				 else if(sender == frameUpDown9) fi->depth = (float)frameUpDown9->get_Value();
				 else if(sender == frameColour){
					 System::Windows::Forms::ColorDialog* cd = new System::Windows::Forms::ColorDialog();
					 if(cd->ShowDialog(this) == DialogResult::OK){
						 fi->diffuse = (DWORD)cd->get_Color().ToArgb();
				 else if(sender == frameMaskCombo){
					 fi->node = __try_cast<TreeNode*>(frameMaskCombo->SelectedItem);

However when I key is pressed and the box had a decimal place the key is entered and the position in the box is moved to the front. So typing 600 in a decimal box will result in typing 006. Anyone have any idea why this only happens to a numeric box when a decimal is used?

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this