New Posts New Posts RSS Feed: Masked Text Entry
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Masked Text Entry

 Post Reply Post Reply
Author
MichaelP View Drop Down
Newbie
Newbie
Avatar

Joined: 07-Aug-2007
Location: Australia
Posts: 12
Post Options Post Options   Quote MichaelP Quote  Post ReplyReply Direct Link To This Post Topic: Masked Text Entry
    Posted: 28-Aug-2007 at 9:53pm
I have a property that represents a General Ledger code, e.g. 123-45-678-9. Is there some way using Data Converter and/or View Descriptor to allow for this formatting to happen whenever a user tries to make an entry in a textbox or grid column data bound to this property?
 
Ideally I would like to set it up so as the user types the start of the GL code 1234 the textbox would show 123-4 etc.
 
After entry I would then need to validate the entry did conform to the required format.
 
I also would like the possibility of optionally popping up an entry form to help them enter the segments of the GL code, e.g. 123 may correspond to a state and 45 may correspond to a department code etc. This could be using a button or double-clicking etc.
 
Can anyone point me in the right direction to do this?
Back to Top
owais,zahid View Drop Down
Newbie
Newbie
Avatar

Joined: 22-Aug-2007
Location: Pakistan
Posts: 8
Post Options Post Options   Quote owais,zahid Quote  Post ReplyReply Direct Link To This Post Posted: 29-Aug-2007 at 6:02am
Nice question MichaelP, its not in my knowledge that ideablade can support the auto formatting of the code. But i can give you a suggestion that might work for you.
 
Divide your questions in 2 part.
 
1) For auto formatting, you should use per-verifier and handle the typing of the user. (not sure it will work).
 
2) Make post verifer that will check the valid input from the user. I have done this thing in order to check the phone number format typed by the user.
Back to Top
MichaelP View Drop Down
Newbie
Newbie
Avatar

Joined: 07-Aug-2007
Location: Australia
Posts: 12
Post Options Post Options   Quote MichaelP Quote  Post ReplyReply Direct Link To This Post Posted: 29-Aug-2007 at 4:04pm
Thanks for the suggestions. I would assume a pre-verifier event would fire after the entry has been completed, i.e. when the user moves to a new field, so that would not allow for the - character to appear when required.
 
I started playing around with a Data Binder to make a custom control for entry, but this doesn't seem to be available in the DataGridViewBindingManager, even though it is available in the ControlBindingManager. Maybe I just can't easily use a .Net DataGridView and need a DevEx or Infragistics grid.
Back to Top
TrevLeyb View Drop Down
Newbie
Newbie
Avatar

Joined: 28-Jun-2007
Location: New Zealand
Posts: 9
Post Options Post Options   Quote TrevLeyb Quote  Post ReplyReply Direct Link To This Post Posted: 29-Aug-2007 at 4:15pm
I think what you may need to do here (assuming you are not using any 3rd party control libraries which do support masked editing) is to create a custom control derived from the TextEdit control. You will then need to create an event handler on the keydown event and on each keypress, reparse/reformat your data and put it back into the control.
 
It can be slightly tricky from memory, but I have done something along these lines before. If you get stuck, let me know and I can try to take a look at mocking something up over the weekend.
 
Trevor
Back to Top
MichaelP View Drop Down
Newbie
Newbie
Avatar

Joined: 07-Aug-2007
Location: Australia
Posts: 12
Post Options Post Options   Quote MichaelP Quote  Post ReplyReply Direct Link To This Post Posted: 29-Aug-2007 at 7:27pm
I have created my own custom textbox control from the Windows.Forms.MaskedTextBox control. That control already has the mask function so I just extended it to suit the GL code formatting I need - i.e. adjustable separator string and adjustable number of segments in the GL code. This works OK.
Next I wanted to add a button on the text box to pop up an alternative entry form, but I haven't had success there. I tried using a usercontrol that includes a textbox and a button, but now the usercontrol is no longer a Windows.Forms.TextBoxBase object and hence I can't use DevForce's TextBoxDataBinder.
For now I think I will just forget about having the button on the databound textbox. I will try adding a double-click event to display the pop up on my custom textbox control and then I can just add a button that I will need to redirect to that double-click event every time I use this textbox control.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down