Home Forums WinForms controls Other WinForms controls Date Mask on WinTextBox

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #18326 |

    Hello,

    I set the WinTextBox’s Textbox mask to a date such as “99-99-9999” and it works fine if I use the mask editor but inconsistently when I set it dynamically at run time. If I enter 11-10-2001, it works fine, but when the first digit in the month and/or day is set to 0, it does not accept this input. I suspect the Validation event is firing and it won’t let me out of the textbox, but it accepts one set of numbers but not another, which leaves me stumped.

    Is there anything else I need to set and any advise you can give me? Thanks.

    Imported from legacy forums. Posted by John (had 4396 views)

    Xceed Support
    Member
    Post count: 5658

    I tried reproducing the error and I was not able.
    I dropped a WinTextBox on my form and a button to set the mask at run time from an other WinTextBox. I did not receive any error. I tried to set the filed starting with a 0 (even if it was only 0s also) and it did not change anything.

    Here is a snippet of the code I used:

    <code>
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim buffer As String
    ‘The text for the Mask, for example “99-99-9999”
    buffer = WinTextBox2.TextBoxArea.Text.ToString()

    WinTextBox1.TextBoxArea.Mask = buffer
    WinTextBox1.Update()
    End Sub
    </code>

    Imported from legacy forums. Posted by CharlesB (had 315 views)

    User (Old forums)
    Member
    Post count: 23064

    Charles,

    I”ve narrow it down some. I can get it to work, but am I correct that I also need to use some type of validation to check the input, such as the ValidationProvider? For instance, if I type “01-01-999” and leave off the last digit for the date, it won’t produce an error and will move the focus to the next control. It seems that the mask is just a depiction of what should be input with no built-in validation, am I correct?

    Thanks for your help.

    Imported from legacy forums. Posted by John (had 343 views)

    Xceed Support
    Member
    Post count: 5658

    You are correct. To input some validation in the process, you will need to override some methods. Here is a link to our documentation that discuss this issue:

    http://doc.xceedsoft.com/products/Xceedgrid/Editors_Adding_mask_characters.html

    Imported from legacy forums. Posted by CharlesB (had 305 views)

    User (Old forums)
    Member
    Post count: 23064

    The problem seems to be related to databinding. If my WinTextBox is bound to a smalldatetime field, the mask will only work when the first digit of day or month is greater than zero. When I change the field type to varchar in SQL Server, it works just find (01/01/2001 is permitted). ‘Just thought I’d post this for the benefit of anyone else.

    Thanks for the great support.

    Imported from legacy forums. Posted by John (had 5259 views)

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.