TextBox & Text

  • Thread starter Thread starter Tod Johnson
  • Start date Start date
T

Tod Johnson

Hello,

have found that TextBox control always resets the vertical scrollbar
position to the beginning in the Multiline mode. When I try to call
"ScrollToCaret" there is really visible flickers. :( Are there
workaround? I'd like just to set text for the TextBox and stay on the
last position.


....
tbConsole.AcceptsReturn = true;
tbConsole.AcceptsTab = true;
tbConsole.Multiline = true;
....

void PutNewText(string t)
{
tbConsole.SelectionStart = tbConsole.Text.Length;
tbConsole.SelectionLength = t.Length;
tbConsole.SelectedText = t;
}


Thanks,
Tod
 
Maybe there are any examples how to write custom readonly TextBox with
the correct carret behaviour?

I have been trying to derive my custom class from the Control to
implement a TextBox behaviour, but it doesn't receive focus and doesn't
receive any keys... :(

Thanks in advance,
Tod
 
Have found that the hwnd gotten in the my custom control constructor
(derived from TextBox) is incorrect. But when I tried to get it
everytime before SendMessage call then everything is fine.

Can't find the explanation for this issue :(

Are any thoughts?
 
Wow! The issue is more strange than I thought. :(

public TextBoxEx()
{
AcceptsReturn = true;
AcceptsTab = true;
Multiline = true;
ScrollBars = ScrollBars.Vertical;

hWnd = GetHWND(); <-- correct handle
}

but

public TextBoxEx()
{
hWnd = GetHWND(); <-- incorrect handle

AcceptsReturn = true;
AcceptsTab = true;
Multiline = true;
ScrollBars = ScrollBars.Vertical;
}
 
You cannot do it in constructor. The control is not created yet. Even if the
first one works.
What you want to do is to add a ParentChanged handler in the constructor and
retrieve hWnd in that handler.
 
Hm, that is really strange. Why does the second method work perfectly?
And also I've seen the implemention of TextBoxEx in the OpenNETCF where
the handle gets in the constructor also.

Anyway thanks, your suggestion seems to be logical!
 
Back
Top