English 中文(简体)
创建一个可迅速更新的无浮标案文箱
原标题:Creating a flicker-free text box that can be rapidly updated

我试图创建搜索工具,希望像视觉演播室中所载的那样,在文字箱中显示结果,这意味着在文字箱子的末尾加上长期搜索结果,而用户正试图在文字箱顶上看结果。

在使用标准文本框时,它有许多问题:

  • The text box flickers madly while the search is in progress
  • Its not possible for the user to scroll while results are being appended to the box
  • Its not possible for the user to copy and paste results in the text box while results are being appended.

是否有办法围绕这些问题开展工作,或者我是否考虑采用另一种控制办法/建立我自己?

最佳回答

微软打算采用文本Box的Begin/EndUpdate()方法。 你可以补充说,解决了这一问题。 你们可以避开浮器。 样本代码:

using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace WindowsFormsApplication1 {
    public partial class Form1 : Form {
        public Form1() {
            InitializeComponent();
            timer1.Interval = 10;
            timer1.Tick += new EventHandler(timer1_Tick);
            button1.Click += new EventHandler(button1_Click);
        }
        void timer1_Tick(object sender, EventArgs e) {
            int pos = textBox1.SelectionStart;
            int len = textBox1.SelectionLength;
            SendMessage(textBox1.Handle, 11, IntPtr.Zero, IntPtr.Zero);
            textBox1.AppendText(DateTime.Now.ToString() + Environment.NewLine);
            SendMessage(textBox1.Handle, 11, (IntPtr)1, IntPtr.Zero);
            //if (textBox1 is RichTextBox) textBox1.Invalidate();
            textBox1.SelectionStart = pos;
            textBox1.SelectionLength = len;
        }
        private void button1_Click(object sender, EventArgs e) {
            timer1.Enabled = !timer1.Enabled;
        }
        [DllImport("user32.dll")]
        private static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wp, IntPtr lp);
    }
}
问题回答

首先,在你进行搜索时,您应将其搜索带入<>条码>,并用<条码>(中文本)查询结果。 因此,在你进行搜捕时,您的智囊团 does。

并请使用<代码>TextBox.AppendText()法将案文添加到你的盒子中。 如果您想在上诉后使用以下两行:

textBoxMessages.SelectionStart = textBoxMessages.Text.Length;
textBoxMessages.ScrollToCaret();

如果选择标准等于文本Lenght,如果你想要使上述两行人在上诉庭之后真正做到的话,那么,如果你想要使你能够进行/可以操作的自动化检查,那么,如果选择标准等于文本文本,那么你就可以在上诉庭之前进行。

Update

为使><>>>>> 浮游,文本箱内没有真正的解决办法。 当我提到权利时,你可以让RichTextBox做一个尝试,因为它能更好地处理这些滚动问题。

http://www.codeplex.com/ScintillaNET“rel=“nofollow noreferer”>ScintillaNET。 我已经多次使用这一方法,并为此解决了所有问题。

唯一能由SintillaNet(或与Sintilla公司相比更好)来做的事情是人工装饰一个习俗部分。 你们总是要使用一种灵活的办法,在关键词清单中采用预先界定的格式。

文本箱对阅读内容来说是好的——检索结果是否正确?

如果你重新展示结果,为什么不使用数据单? 你们可以设计它来研究你们的希望(可以look<>/em>)。 文本箱,有浏览器和纸浆;文本浏览器





相关问题
Bring window to foreground after Mutex fails

I was wondering if someone can tell me what would be the best way to bring my application to the foreground if a mutex was not able to be created for a new instance. E.g.: Application X is running ...

How to start WinForm app minimized to tray?

I ve successfully created an app that minimizes to the tray using a NotifyIcon. When the form is manually closed it is successfully hidden from the desktop, taskbar, and alt-tab. The problem occurs ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

Handle DataTable.DataRow cell change event

I have a DataTable that has several DataColumns and DataRow. Now i would like to handle an event when cell of this DataRow is changed. How to do this in c#?

Apparent Memory Leak in DataGridView

How do you force a DataGridView to release its reference to a bound DataSet? We have a rather large dataset being displayed in a DataGridView and noticed that resources were not being freed after the ...

ALT Key Shortcuts Hidden

I am using VS2008 and creating forms. By default, the underscore of the character in a textbox when using an ampersand is not shown when I run the application. ex. "&Goto Here" is not ...

WPF-XAML window in Winforms Application

I have a Winforms application coded in VS C# 2008 and want to insert a WPF window into the window pane of Winforms application. Could you explain me how this is done.