c# - How to simulate windows keyboard text selection -


i attempting duplicate way windows selects text via combinations of shift control , arrow keys.

my current attempt, assume grid text box.

        dim selectionstart integer = grid.activecell.selstart         if e.keycode = keys.right             if not e.shift                 grid.activecell.selstart = selectionstart + 1                 grid.activecell.sellength = 0             else                 grid.activecell.sellength += 1                 'grid.activecell.selstart = selectionstart + 1             end if         elseif e.keycode = keys.left             if not e.shift                 if selectionstart > 0 andalso not e.control                      grid.activecell.selstart = selectionstart - 1                 end if                 grid.activecell.sellength = 0             else                 if selectionstart > 0                     if not e.control                         grid.activecell.selstart -= 1                         grid.activecell.sellength += 1                     end if                 end if                 end if             end if         end if 

while close cases don't work properly. there better or standard way?


Comments