<small id='7G1hs'></small><noframes id='7G1hs'>

  1. <legend id='7G1hs'><style id='7G1hs'><dir id='7G1hs'><q id='7G1hs'></q></dir></style></legend>
    <tfoot id='7G1hs'></tfoot>
      <bdo id='7G1hs'></bdo><ul id='7G1hs'></ul>

    <i id='7G1hs'><tr id='7G1hs'><dt id='7G1hs'><q id='7G1hs'><span id='7G1hs'><b id='7G1hs'><form id='7G1hs'><ins id='7G1hs'></ins><ul id='7G1hs'></ul><sub id='7G1hs'></sub></form><legend id='7G1hs'></legend><bdo id='7G1hs'><pre id='7G1hs'><center id='7G1hs'></center></pre></bdo></b><th id='7G1hs'></th></span></q></dt></tr></i><div id='7G1hs'><tfoot id='7G1hs'></tfoot><dl id='7G1hs'><fieldset id='7G1hs'></fieldset></dl></div>
    1. 如何在文本框顶部绘图

      时间:2023-06-09
      1. <i id='pS7Ph'><tr id='pS7Ph'><dt id='pS7Ph'><q id='pS7Ph'><span id='pS7Ph'><b id='pS7Ph'><form id='pS7Ph'><ins id='pS7Ph'></ins><ul id='pS7Ph'></ul><sub id='pS7Ph'></sub></form><legend id='pS7Ph'></legend><bdo id='pS7Ph'><pre id='pS7Ph'><center id='pS7Ph'></center></pre></bdo></b><th id='pS7Ph'></th></span></q></dt></tr></i><div id='pS7Ph'><tfoot id='pS7Ph'></tfoot><dl id='pS7Ph'><fieldset id='pS7Ph'></fieldset></dl></div>
        <legend id='pS7Ph'><style id='pS7Ph'><dir id='pS7Ph'><q id='pS7Ph'></q></dir></style></legend>
      2. <small id='pS7Ph'></small><noframes id='pS7Ph'>

          <tfoot id='pS7Ph'></tfoot>
          • <bdo id='pS7Ph'></bdo><ul id='pS7Ph'></ul>
              <tbody id='pS7Ph'></tbody>

                本文介绍了如何在文本框顶部绘图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我有一个带有 TextBox 的 winform,我想在它上面绘制一些 GDI 图形.文本框没有要挂钩的 Paint() 事件,所以我认为这一切都必须发生在表单的 Paint 事件中.作为测试,我正在从原点绘制一个矩形到文本框中的某个位置:

                I have winform with a TextBox and I want to draw some GDI graphics on top of it. The text box does not have a Paint() event to hook to, so I assume it all has to happeen within the form's Paint event. As a test I am drawing a rectangle from the origin to a location within the text box with:

                    private void FindForm_Paint(object sender, PaintEventArgs e)
                    {
                        using (Pen pen = new Pen(Color.Blue))
                        {
                            e.Graphics.DrawRectangle(pen, 0, 0, point.X, point.Y);
                        }
                    }
                

                问题是当我运行时,首先绘制完成,然后在我的行之上渲染文本框.我想在文本框渲染后画线.

                The problem is that when I run, the drawing is done first, and then the text box is rendered, on top of my lines. I want to draw the lines after the text box is rendered.

                PS.我没有使用 Form.SetStyle() 函数对表单进行任何设置.

                PS. I have not made any settings for the form with the Form.SetStyle() function.

                推荐答案

                所有者绘制 TextBox 控件可能相对棘手,因为它只是原生 Win32 TextBox<的包装器/code> 控制.

                It can be relatively tricky to owner-draw the TextBox control because it's simply a wrapper around the native Win32 TextBox control.

                捕获WM_PAINT 消息的最简单方法是从NativeWindow 类.

                The easiest way to capture the WM_PAINT messages that you need to handle for your custom painting routines to work is by inheriting from the NativeWindow class.

                这是一篇出色的分步文章,展示了如何在显示红色波浪下划线的情况下执行此操作:Owner-drawing a Windows.Forms TextBox (原链接失效; 替换为存档版本)

                Here is an excellent step-by-step article that shows how to do this in the context of displaying the red wavy underlines: Owner-drawing a Windows.Forms TextBox (original link dead; replaced by archived version)

                这篇关于如何在文本框顶部绘图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                <i id='UxZEL'><tr id='UxZEL'><dt id='UxZEL'><q id='UxZEL'><span id='UxZEL'><b id='UxZEL'><form id='UxZEL'><ins id='UxZEL'></ins><ul id='UxZEL'></ul><sub id='UxZEL'></sub></form><legend id='UxZEL'></legend><bdo id='UxZEL'><pre id='UxZEL'><center id='UxZEL'></center></pre></bdo></b><th id='UxZEL'></th></span></q></dt></tr></i><div id='UxZEL'><tfoot id='UxZEL'></tfoot><dl id='UxZEL'><fieldset id='UxZEL'></fieldset></dl></div>

                      <tbody id='UxZEL'></tbody>

                  • <legend id='UxZEL'><style id='UxZEL'><dir id='UxZEL'><q id='UxZEL'></q></dir></style></legend>

                    <small id='UxZEL'></small><noframes id='UxZEL'>

                  • <tfoot id='UxZEL'></tfoot>

                        <bdo id='UxZEL'></bdo><ul id='UxZEL'></ul>