numerical entry control

  • Thread starter Thread starter colin
  • Start date Start date
C

colin

Hi,
Is there a simple numerical data entry control ?

I had a look at the
http://www.codeproject.com/cs/miscctrl/HDNumericTextBox.asp

wich seemed to be what I wanted but it doesnt seem to work,
when I try and put it on the form using the designer it gives the error :-

---------------------------
Microsoft Visual C# 2005 Express Edition
---------------------------
Failed to create component 'NumericTextBox'. The error message follows:
'System.FormatException: Input string was not in a correct format.
at System.ComponentModel.ReflectPropertyDescriptor.SetValue(Object
component, Object value)
at
System.Windows.Forms.Design.ControlDesigner.InitializeNewComponent(IDictionary
defaultValues)
at
System.Windows.Forms.Design.TextBoxBaseDesigner.InitializeNewComponent(IDictionary
defaultValues)
at System.Drawing.Design.ToolboxItem.CreateComponentsCore(IDesignerHost
host, IDictionary defaultValues)
at System.Drawing.Design.ToolboxItem.CreateComponents(IDesignerHost host,
IDictionary defaultValues)
at System.Windows.Forms.Design.OleDragDropHandler.CreateTool(ToolboxItem
tool, Control parent, Int32 x, Int32 y, Int32 width, Int32 height, Boolean
hasLocation, Boolean hasSize, ToolboxSnapDragDropEventArgs e)'
 
Hi,
Is there a simple numerical data entry control ?

I had a look at thehttp://www.codeproject.com/cs/miscctrl/HDNumericTextBox.asp

wich seemed to be what I wanted but it doesnt seem to work,
when I try and put it on the form using the designer it gives the error :-

---------------------------
Microsoft Visual C# 2005 Express Edition
---------------------------
Failed to create component 'NumericTextBox'. The error message follows:
'System.FormatException: Input string was not in a correct format.
at System.ComponentModel.ReflectPropertyDescriptor.SetValue(Object
component, Object value)
at
System.Windows.Forms.Design.ControlDesigner.InitializeNewComponent(IDictionary
defaultValues)
at
System.Windows.Forms.Design.TextBoxBaseDesigner.InitializeNewComponent(IDictionary
defaultValues)
at System.Drawing.Design.ToolboxItem.CreateComponentsCore(IDesignerHost
host, IDictionary defaultValues)
at System.Drawing.Design.ToolboxItem.CreateComponents(IDesignerHost host,
IDictionary defaultValues)
at System.Windows.Forms.Design.OleDragDropHandler.CreateTool(ToolboxItem
tool, Control parent, Int32 x, Int32 y, Int32 width, Int32 height, Boolean
hasLocation, Boolean hasSize, ToolboxSnapDragDropEventArgs e)'
---------------------------

says .net 1.1 does it need to be modified for .net2 ?

Colin =^.^=

I'm not sure if it will meet your needs, but have you tried the
MaskedTextBox?

Chris
 
U¿ytkownik "colin said:
Hi,
Is there a simple numerical data entry control ?

I had a look at the
http://www.codeproject.com/cs/miscctrl/HDNumericTextBox.asp

wich seemed to be what I wanted but it doesnt seem to work,
when I try and put it on the form using the designer it gives the error :-

---------------------------
Microsoft Visual C# 2005 Express Edition
---------------------------
Failed to create component 'NumericTextBox'. The error message follows:
'System.FormatException: Input string was not in a correct format.
at System.ComponentModel.ReflectPropertyDescriptor.SetValue(Object
component, Object value)
at
System.Windows.Forms.Design.ControlDesigner.InitializeNewComponent(IDictionary
defaultValues)
at
System.Windows.Forms.Design.TextBoxBaseDesigner.InitializeNewComponent(IDictionary
defaultValues)
at System.Drawing.Design.ToolboxItem.CreateComponentsCore(IDesignerHost
host, IDictionary defaultValues)
at System.Drawing.Design.ToolboxItem.CreateComponents(IDesignerHost
host, IDictionary defaultValues)
at System.Windows.Forms.Design.OleDragDropHandler.CreateTool(ToolboxItem
tool, Control parent, Int32 x, Int32 y, Int32 width, Int32 height, Boolean
hasLocation, Boolean hasSize, ToolboxSnapDragDropEventArgs e)'
---------------------------

says .net 1.1 does it need to be modified for .net2 ?

Colin =^.^=

http://www.codeproject.com/cs/miscctrl/ValidatingTextBoxControls.asp

this control works fine :)

Regards
Sebastian
 
This is a simple, quick and dirty solution;

Add a textbox to a form and then capture the Key Press Event. Then
add the following code within the key press event. As I said this is
quick and dirty and does not cover the numeric key pad. Hopefully
this will give you something to start with.

private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{

switch (e.KeyChar)
{
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
e.Handled = false;
break;

default:
e.Handled = true;
break;

}
}

Cheers
Robb
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top