Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
725
Totally lost - WinGrid & UltraMaskedEdit
posted

Rather than trying to explain all the different odd (to me anyway) behavior I'm seeing, I'll just explain the result I'm trying to get and see if someone can point me in the right doirection.

I have a data bound grid that has one particular column of data that is a 20 Char (Max - typical is 18) "Point Identifier" (or PID).

These PID's contain information based on the character(s) at a given fixed position within the string.

Previously I have simply been displaying a status bar pane with "Next Char at: " to indicate to the user where they are in the string.

What I want to be able to do is:

Display a delimiter mark (a Pipe character) between the 8th & 9th character and a second one between the 18th & 19 character.

Also - since character position is important, I have written key handler routines that simulate an overstrike mode (including a handler for backspace that leave an empty space in place of the removed character). I need to retain this functionality as well.

Currently I am having several issues trying to incorporate this - I've listed 2 below as examples but these are not the only problems I've encountered.

A sample PID would look something like this: DOGBERT_BS1______H__ (underscores used to show blank spaces)

Using a .MaskInput of  ">CCCCCCCC|CCCCCCCCCC|CC" the PID looks like DOGBERT_|BS1______H|__

Ex 1 - if I am editing a PID that has a space in the 8th character I can set my insertion point in front of the space & type 1 character. I cannot type any further without arrowing over the delimiter character. (trying to type anything between the T & B in the example PID)

Ex 2 - When I added back my keyboard handlers - if I start typing with the 8th character when I press a key for the 9th character it erases anything already between the 2 delimiter marks (Typing in 2 characters after the T causes the BS1_______H to disappear).

 

Here are the setting I have for the PID column :

.Header.VisiblePosition = 0

.Header.Fixed = True

.CharacterCasing = CharacterCasing.Upper

.MaxLength = 20

.AutoSizeMode = ColumnAutoSizeMode.None

.MaxWidth = 220

.MinWidth = 220

' Add mask settings for cell to show 8th & 18th character break.

.MaskInput = ">CCCCCCCC|CCCCCCCCCC|CC"

' Copy to clipboard without mask characters

.MaskClipMode = UltraWinMaskedEdit.MaskMode.Raw

' Store without mask characters

.MaskDataMode = UltraWinMaskedEdit.MaskMode.Raw

' Display without mask characters when not in edit mode

.MaskDisplayMode = UltraWinMaskedEdit.MaskMode.Raw

' Change appearance of mask characters

With .MaskLiteralsAppearance

.ForeColor = Red

End With

 

And here are my keyboard handlers (placed in the grid _keydown event)

With ugPIDdata.ActiveCell

Select Case e.KeyValue

Case Is = 8 ' Backspace key

If .SelStart > 0 Then .SelStart = .SelStart - 1

.SelLength = 1

.SelText = " "

.SelStart = .SelStart - 1

Case Is = 32 ' Space Bar

.SelLength = 1

Case Is = 46 'Delete key

.SelLength = 0

.SelText = " "

Case 48 To 57, 65 To 90, 190, 191, 220 '0 to 9, A to Z,.,/,\

If .SelLength = 0 Then .SelLength = 1

Case Else

Exit Sub

End Select

 

 I know that there are litteraly TONS of other things going on in my program that could be affecting this, so I have modifyed the sample program for "Cell Formatting using Mask" to incorporate a data field that simulates these PID's and I get the same behavior from it as well. 

 Not sure what I'm doing really so I can't be sure what I'm doing wrong so any and all advice is greatly appreciated.

Thanks in advance.

  • 71886
    Offline posted

    Hello n2dfire,

    To Ex 1: This might happen, because the editor is not in insert mode. You could set the mode like this:

    
    

    Dim

    editor As EditorWithMask = DirectCast(UltraGrid1.ActiveCell.EditorResolved, EditorWithMask)

    editor.ToggleInsertMode()

    As to Ex 2: You could use an approach like the following in order to resolve the issue you are having:

       Case 48 To 57, 65 To 90, 190, 191, 220 '0 to 9, A to Z,.,/,\

                        Dim editor As EditorWithMask = DirectCast(UltraGrid1.ActiveCell.EditorResolved, EditorWithMask)
                        If UltraGrid1.ActiveCell.SelLength = 0 Then UltraGrid1.ActiveCell.SelLength = 1

                        If editor.SelectionStart = 8 Then
                            UltraGrid1.ActiveCell.SelLength = 0
                            editor.SelectionStart = 9
                        End If

                        If editor.SelectionStart = 19 Then
                            UltraGrid1.ActiveCell.SelLength = 0
                            editor.SelectionStart = 20
                        End If

                        If editor.SelectionStart <> 8 And editor.SelectionStart <> 19 Then UltraGrid1.ActiveCell.SelLength = 1

    
    

    
    

    Please feel free to let me know if I misunderstood you or if you have any other questions.