vb.net - Text box cursor manipulation -
i had quite bit of luck yesterday finding solution problem, i've come new one.
my programme multi-tab calculator, , user inputs aiming total keyboard navigation. have boxes laid out in grid, , have keydown subs each box trap arrow keys, allowing user navigate between boxes using arrows.
the flaw find in this, if input boxes , create error (during runtime), either have backspace x number of times , retype, or click cursor position alter single character. seeing need utilize left , right arrows navigate cursor position within textboxes, retain of navigation function.
so have few questions based off of this.
is there way observe cursor position in text control? if so, said cursor position numeric? i.e. position = 0 @ start of box, position = 1 between first , sec characters , forth.
i trying write sub count characters in string, decide if cursor on left or right of said string , allow appropriate move next box when is.
private sub countcharacters() 'i'm not sure of syntax yet, i'm researching currently, please bear 'me, i'm trying concept across. dim txtboxcount integer txtboxcount = txtbox1.text.count '??? dim txtboxpos integer txtbox1.cursor.position.get '??? end sub private sub onkeydown() countcharacters() if e.keydata = keys.left e.suppresskeypress = true 'as i'm typing this, realize might need alter this, 'for suppressing beeps if txtboxpos > 0 move cursor left within box '??? else if txtboxpos = 0 nextboxleft.focus() end if end if end sub
anyhow, i'm researching this, , work find own answer. hoping there might out there can shed lite onto if such thing possible, , if i'm on right track?
be gentle, i'm self teaching , have been @ few weeks.
i'm not sure understood how controls laid out on form, textbox have property tells caret is, , it's called selectionstart.
despite name, works when no text actually selected.
oh, , don't need write method determine length of string: utilize length property. since you're new, remember strings can null
(or nothing
in vb parlance), need check if that's case before using length
. speaking, text
property won't null
, want maintain in mind.
vb.net
No comments:
Post a Comment