0 Replies Latest reply on Jan 22, 2017 7:37 AM by Checkcheck Master

    ComboBox Filter Characters while in Append/Suspend mode

    Checkcheck Master

      Hi there,

       

      This question is not SolidWorks but VB.NET related.

      In a ComboBox I try to remove some unwanted characters and character combinations with the familiar commands like Replace, Instr, Length etc.

      For example:

           Value = Value.Replace("  ", " ")

           Value = Value.Replace("\", "")

           Value = Value.Replace("/", "")

           Value = Value.Replace(":", "")

           'Value = Value.Replace("*", "")

      Or:

           'Avoid space at first position

                If InStr(Value, " ") = 1 Then

                     Value = Value.Substring(0, Value.Length - 1)

                End If

       

      When a change is made the cursor position is set to the first position of the string which I try to control by:

      BoxName.SelectionStart = i, where i is an Integer representing the cursor position determined before the change was made.

       

      My problem is that when the ComboBox is in AutoCompleteMode.None everything works just fine as expected.

      But when the ComboBox is in AutoCompleteMode.Append or Suspend I'l get some unwanted behavior which i can't get under control.

      For example, sometimes it's stil possible to type and see the unwanted characters and spaces till you hit a next button where after it's corrected.

      Selectionstart command is doing strange.

      It just looks sloppy.

       

      I did not see any difference between when the actions are taken directly onder the Change event or in a separate routine with a ByRef variable.

       

      Anyone familiar with this?

       

      Greetings!