DomainUpDown key input

  • Thread starter Thread starter slamb
  • Start date Start date
S

slamb

I was hoping someone could describe how DomainUpDown control,
ReadOnly=true, is supposed to react to key input.


I'm using a DomainUpDown to contain a list of grades, A, B, C, D, F.
When the user enters a number via the keypad, the control selects a
grade, 1->A, 2->B, 3->C, 4->D, 6->F. This is not desirable. When the
user enters a number via the standard keys, the control doesn't select
a grade.

Any ideas why it is treating these types of input differently?

Is there anyway to turn off this behavior without having to derive from
DomainUpDown? If derivation is required, what exactly must be done?


Another option is to map certain numbers, i.e. numeric key input (both
key pad and normal number keys), to grades, this is useful in my
context because grades are also represented numerically, A=4, B=3, C=2,
D=1, F=0. What would be the best way to do this?


Thanks in advance.
 
// Oops forgot to provide the code.

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace WindowsApplication5
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.DomainUpDown domainUpDown1;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;

public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.domainUpDown1 = new System.Windows.Forms.DomainUpDown();
this.SuspendLayout();
//
// domainUpDown1
//
this.domainUpDown1.Items.Add("A");
this.domainUpDown1.Items.Add("B");
this.domainUpDown1.Items.Add("C");
this.domainUpDown1.Items.Add("D");
this.domainUpDown1.Items.Add("F");
this.domainUpDown1.Location = new System.Drawing.Point(78, 107);
this.domainUpDown1.Name = "domainUpDown1";
this.domainUpDown1.ReadOnly = true;
this.domainUpDown1.TabIndex = 0;
this.domainUpDown1.Text = "A";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 273);
this.Controls.Add(this.domainUpDown1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);

}
#endregion

/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
}
}
 
Back
Top