wx.SampleGrid.NumericInput Class Reference

A small specialization of a TextCtrl for numeric input. More...

List of all members.

Public Member Functions

 NumericInput (Window parent, int id, int defaultValue, System.Drawing.Point pos, System.Drawing.Size size)
 NumericInput (Window parent, int id, int defaultValue)
void OnChar (object sender, Event e)

Properties

int MaxValue [get, set]
 The maximum value.
new string Value [get, set]
 Sets and gets the text value.


Detailed Description

A small specialization of a TextCtrl for numeric input.

This class is a prerequisite for the NumericGridEditor which is an example for a C# implementation of a GridCellEditor. It only allows digits as input. Optionally, a MaxValue() may be specified for the input values. Refer to remarks on BigGridFrame.

Definition at line 1361 of file Grid.cs.


Constructor & Destructor Documentation

wx.SampleGrid.NumericInput.NumericInput ( Window  parent,
int  id,
int  defaultValue 
)

Definition at line 1364 of file Grid.cs.

01365                         : base(parent, id, defaultValue.ToString(), wxDefaultPosition, wxDefaultSize)
01366                 {
01367                         Char += new EventListener( OnChar );
01368                 }

wx.SampleGrid.NumericInput.NumericInput ( Window  parent,
int  id,
int  defaultValue,
System.Drawing.Point  pos,
System.Drawing.Size  size 
)

Definition at line 1370 of file Grid.cs.

01371                         : base(parent, id, defaultValue.ToString(), pos, size)
01372                 {
01373                         Char += new EventListener( OnChar );
01374                 }


Member Function Documentation

void wx.SampleGrid.NumericInput.OnChar ( object  sender,
Event  e 
)

Definition at line 1381 of file Grid.cs.

01382                 {
01383             if (e is KeyEvent)
01384             {
01385                 KeyEvent kev=(KeyEvent) e;
01386                 if (kev.KeyCode >= '0' && kev.KeyCode <= '9')
01387                 {
01388                   if ((int)InsertionPoint >= Value.Length)
01389                   {
01390                      Value=Value+new string((char) kev.KeyCode, 1);
01391                   }
01392                   else
01393                   {
01394                     Value=Value.Substring(0, (int)InsertionPoint)
01395                         +new string((char) kev.KeyCode, 1)
01396                         +Value.Substring((int)InsertionPoint);
01397                   }
01398                 }
01399                 else if (kev.KeyCode==(int)KeyCode.WXK_DELETE
01400                     || kev.KeyCode==(int)KeyCode.WXK_BACK
01401                     || kev.KeyCode >= 256)
01402                 {
01403                     kev.Skip();
01404                 }
01405                          
01406             }
01407                 }


Property Documentation

int wx.SampleGrid.NumericInput.MaxValue [get, set]

The maximum value.

This might be null in case of unconstrained input.

Definition at line 1379 of file Grid.cs.

Referenced by wx.SampleGrid.NumericGridEditor.Create().

new string wx.SampleGrid.NumericInput.Value [get, set]

Sets and gets the text value.

On setting the value: A value containing non-digits will be ignored. If minimum or maximum is exceeded, either a text representation of the minimum is set or the last digits of the value will be selected.

Definition at line 1415 of file Grid.cs.

Referenced by wx.SampleGrid.NumericGridEditor.BeginEdit(), wx.SampleGrid.NumericGridEditor.EndEdit(), and wx.SampleGrid.NumericGridEditor.StartingKey().


Manual of the wx.NET   (c) 2003-2010 the wx.NET project