在文本框上设置文本,无需更改光标位置 [英] Set Text on Textbox w/o changing cursor pos

查看:73
本文介绍了在文本框上设置文本,无需更改光标位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个.Net TextBox(真的是TextBoxBase),我每秒附加大约20

行文本。我使用AppendText()方法来实现这一目标。

这是取代Text属性并连接

的绝佳替代品...

Me.tb.Text& = newText

''而是使用

Me.tb.AppendText(newText)


....最终将SelectionStart设置为TextBox的末尾,

SelectionLength为新文本的长度并替换SelectedText

(通过SendMessage API函数,使用Lutz Roeder的

反射器确定。


这会将光标保持在TextBox的末尾,因为文本被附加到它没有闪烁的
。我希望执行相同的功能,但保持光标

位置(如果它不在TextBox的末尾)。如果我在附加文本并恢复它们之前坚持选择位置和长度

aftrer,它会产生AWFUL闪烁。


是否有我可以发送的消息,可能使用SendMessage API,

附加文字但不改变位置或选择?


图片在调试时调用Visual Studio中的输出窗口并以相同的速率调用
Debug.WriteLine(newText)。如果光标设置在TextBox的末尾

,它会在写入行时保持在最后。如果您选择一些

文本,您的选择将保持原样,但仍会附加文本。这就是我想要做的事情。


Dim i As Integer

i = 0到10000

Debug.WriteLine(我正在写行& i)

下一页


任何帮助都是赞赏。

提前致谢。


WALDO

解决方案

WALDO写道:


我有一个.Net TextBox



对你有好处。

但请不要在任何经典的VB新闻组中发布它。


如果它没有说dotnet (或vsnet)然后它不适合dotnet。

谢谢,

Bob

MS MVP - VB,2000- 2006

-


它发布到microsoft.public.vb.winapi因为我正在寻找一个

SendMessage消息。我认为这符合资格。


如果你有答案或关闭

,如果你不这样做的话,它是不是花费更少的精力去帮助不仅仅是一个屁股?难道不是很累,鲍勃?


-


任何帮助都表示赞赏。

谢谢提前。


WALDO


" Bob O`Bob" < fi ******* @ yahoogroups.com写信息

新闻:Og ************** @ TK2MSFTNGP04.phx.gbl ...


WALDO写道:


>我有一个.Net TextBox


对你有好处。

但是请不要在任何经典的VB新闻组中发布它。


如果它并没有说dotnet (或vsnet)然后它不适用于dotnet。


谢谢,


Bob

MS MVP - VB,2000-2006

-



WALDO< NO **** @ NOSPAM.comschrieb im Beitrag

< OA ************** @ TK2MSFTNGP03.phx.gbl> ...


它发布到microsoft.public.vb.winapi,因为我正在寻找一个

SendMessage消息。我认为这符合条件。



为什么不在C(++)小组中问你的问题呢?人们

确实知道很多关于SendMessage?是的,因为C(++)和VB.NET是不同语言的
。知道了,让我们确保您的VB.NET和VB也是不同的语言。


它不会消耗更少的能量如果你有答案或关闭





如果你不'不仅仅是一个屁股?鲍勃,这不是很累吗?



未来这个问题可以被忽略。好的

再见!


-

----------------- -------------------------------------------------- ---

THORSTEN ALBERS Universit?t Freiburg

albers @

uni-freiburg.de

- -------------------------------------------------- ------------------


I have a .Net TextBox (TextBoxBase, really) in which I am appending about 20
lines of text per second. I use the AppendText() method to accomplish this.
This is a great substitute for taking the Text property and concatenating
it...

Me.tb.Text &= newText
'' Instead use
Me.tb.AppendText(newText)

....ultimately setting the SelectionStart to the end of TextBox, the
SelectionLength to the length of the new text and replacing the SelectedText
(via the SendMessage API function, determined by using Lutz Roeder''s
Reflector).

This keeps the cursor at the end of the TextBox as text is appended to it
without flicker. I wish to perform this same function, but keep the cursor
position where it is (if it is not at the end of the TextBox). If I persist
the selection position and length before I append the text and restore them
aftrer, it creates AWFUL flicker.

Is there a message I can send, maybe using the SendMessage API, that will
append text but not change the position or the selection?

Picture the Output Window in Visual Studio as you are debugging and calling
Debug.WriteLine(newText) at the same rate. If your cursor is set at the end
of the TextBox, it stays at the end as lines are written. If you select some
text, your selection stays where it is, but text is still appended. That''s
exactly what I''m trying to do.

Dim i As Integer
For i = 0 To 10000
Debug.WriteLine("I am writing line " & i)
Next

Any help is appreciated.
Thanks in advance.

WALDO

解决方案

WALDO wrote:

I have a .Net TextBox

Good for you.
But please do not post about it in any of the classic VB newsgroups.

If it doesn''t say "dotnet" (or "vsnet") then it isn''t for dotnet.
thanks,
Bob
MS MVP - VB, 2000-2006
--


It is posted to microsoft.public.vb.winapi because I am looking for a
SendMessage message. I think that qualifies.

Doesn''t it expend less energy to help if you you have an answer or shut the
hell up if you don''t than to just be an ass? Isn''t it exhausting, Bob?

--

Any help is appreciated.
Thanks in advance.

WALDO

"Bob O`Bob" <fi*******@yahoogroups.comwrote in message
news:Og**************@TK2MSFTNGP04.phx.gbl...

WALDO wrote:

>I have a .Net TextBox


Good for you.
But please do not post about it in any of the classic VB newsgroups.

If it doesn''t say "dotnet" (or "vsnet") then it isn''t for dotnet.
thanks,
Bob
MS MVP - VB, 2000-2006
--



WALDO <NO****@NOSPAM.comschrieb im Beitrag
<OA**************@TK2MSFTNGP03.phx.gbl>...

It is posted to microsoft.public.vb.winapi because I am looking for a
SendMessage message. I think that qualifies.

Why then don''t you ask your question in a C(++) group as well where people
do know a lot about SendMessage? Right, because C(++) and VB.NET are
different languages. Know, let us ensure you that VB.NET and VB are
different languages as well.

Doesn''t it expend less energy to help if you you have an answer or shut

the

hell up if you don''t than to just be an ass? Isn''t it exhausting, Bob?

This for the future qualifies questions of yours as to be ignored. Good
bye!

--
----------------------------------------------------------------------
THORSTEN ALBERS Universit?t Freiburg
albers@
uni-freiburg.de
----------------------------------------------------------------------


这篇关于在文本框上设置文本,无需更改光标位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆