c# - Programatically enable RichTextBox and show caret -


for application working on, have usercontrol added form programatically several times. part of usercontrol richtextbox set transparent , has click functionality disabled acts more label , blends user control.

when user control deliberately clicked user, richtextbox's background changed white, isreadonly set false, , clicking enabled.

the problem trying correct user still has click on richtextbox second time enable caret prior typing. googling , code attempts programatically set caret haven't worked. suggestions why below code isn't working? there else need do?

 contentbox.ishittestvisible = true;  contentbox.background = new solidcolorbrush(color.fromrgb(240, 240, 240));  contentbox.isreadonly = false;  //manage caret position  textpointer newpointer = contentbox.caretposition;  newpointer = newpointer.documentend;  contentbox.caretposition = newpointer; 

i think missing setting logical , keyboard focus control afterwards. try

dispatcher.begininvoke(     new action(delegate()     {         contentbox.focus();         // set logical focus         system.windows.input.keyboard.focus(contentbox); // set keyboard focus     }) ); 

Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -