如何将我的system.windows.forms.panel上完成的内容复制到文本框中 [英] How to copy what's done on my system.windows.forms.panel to a textbox

查看:58
本文介绍了如何将我的system.windows.forms.panel上完成的内容复制到文本框中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

panel1_MouseMove属性内部的代码如下:C#



Inside of the panel1_MouseMove Properties is the code below: C#

private void panel1_MouseMove(object sender, MouseEventArgs e)
{
    if (paint) 
    {
        color = new SolidBrush(Color.Black);
        Graphics g = panel1.CreateGraphics();
        g.FillEllipse(color, e.X, e.Y, 10, 10);

        //e is the mouse, in this case e.X is the current X Position of the mouse, and same with Y Position.
        g.Dispose();
    }
}



上面的代码允许我使用面板作为表面进行绘画,就像你想要的那样

你正在使用Microsoft Paint。



我要做的是复制到文本框中我在
$ b中绘制的内容在运行时窗口上$ b panel1。



我尝试过:



我试过textbox1.Text = textbox1.Text + panel1.BackColor;



唯一转移到文本的是Color {Control )。



我需要在运行时将表格上的panel1上绘制的内容转移到

textbox1。


The Code above allows me to use the panel as a surface to paint on like you would if
you're using Microsoft Paint.

What I'm trying to do is to copy to a textbox what I have painted in the
panel1 on the windows form during run-time.

What I have tried:

I have tried textbox1.Text = textbox1.Text + panel1.BackColor;

The only thing that transfer over to the text is Color{Control).

I need what I painted on the panel1 on the form at runtime to be transferred over to
the textbox1.

推荐答案

简单的答案是,它不可能,TextBox控件只能处理文本,这就是为什么BackColor属性的文字文本写入框中的原因。
The simple answer is that it is not possible, a TextBox control is designed to handle text only, which is why the literal text of the property BackColor is written into the box.


[未经测试]



您可以使用图层。将TextBox背景设置为透明,并将其放在另一个Panel的顶部。然后将此面板设置为与您正在绘制的面板相匹配。
[not tested]

You can by using layers. Set the TextBox background to transparent and put it on top of another Panel. Then you set this panel to match the Panel that you are drawing in.


这篇关于如何将我的system.windows.forms.panel上完成的内容复制到文本框中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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