请教高人:文本框中怎么绘制图形? WinForm中自定义文本框中怎么绘制图形?比如一条直线.有解出再加50分,谢~~~~~~~~~~~~~~~~ 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 继承自Textbox的控件在onpain事件中的操作无效.MSDN有这样一句话:注意 某些 Windows 窗体控件(如 TextBox)是由 Windows 直接绘制的。在这些情况中,永远不调用 OnPaint 方法, 可以的吧,我这段代码试过了,当鼠标移上去时画一直线using System;using System.Collections;using System.ComponentModel;using System.Drawing;using System.Data;using System.Windows.Forms;namespace contro_lset{ /// <summary> /// mybutton 的摘要说明。 /// </summary> public class mybutton : System.Windows.Forms.TextBox { /// <summary> /// 必需的设计器变量。 /// </summary> private System.ComponentModel.Container components = null; public mybutton() { // 该调用是 Windows.Forms 窗体设计器所必需的。 InitializeComponent(); this.Width=100; this.Height=75; MouseEnter+=new EventHandler(OnMouseEnter); // TODO: 在 InitComponent 调用后添加任何初始化 } /// <summary> /// 清理所有正在使用的资源。 /// </summary> protected override void Dispose( bool disposing ) { if( disposing ) { if( components != null ) components.Dispose(); } base.Dispose( disposing ); } #region 组件设计器生成的代码 /// <summary> /// 设计器支持所需的方法 - 不要使用代码编辑器 /// 修改此方法的内容。 /// </summary> private void InitializeComponent() { components = new System.ComponentModel.Container(); } #endregion protected override void OnPaint(PaintEventArgs pe) { pe.Graphics.DrawLine(new Pen(Color.Blue),0,4,80,5); } private void OnMouseEnter(object o,System.EventArgs e) { OnPaint(new PaintEventArgs(this.CreateGraphics(),this.ClientRectangle)); } }} 读取并删除记事本文件中的第一行代码应该怎么写? C# WinForm 界面控件美化? 求教:SOCKET多线程传文件的原理,TCP (100分,在另一个帖子中,目前没人) 菜鸟问题!关于树的!请师兄们指教 如何从shell32.dll中另存导出驱动器图标? 关于脚本的小问题,马上结:) 为什么我的vc#一设断点想调试程序就会死机!:( 求一个xPath表达式 dll调用 那里有C#数据库方面的书!! 控制台的托盘程序如何在关闭控制台时把托盘图标去掉。在线等,急 求一正则表达式!!! 将文本框中用 [ ] 中的字符取出.
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;namespace contro_lset
{
/// <summary>
/// mybutton 的摘要说明。
/// </summary>
public class mybutton : System.Windows.Forms.TextBox
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public mybutton()
{
// 该调用是 Windows.Forms 窗体设计器所必需的。
InitializeComponent();
this.Width=100;
this.Height=75;
MouseEnter+=new EventHandler(OnMouseEnter);
// TODO: 在 InitComponent 调用后添加任何初始化
} /// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if( components != null )
components.Dispose();
}
base.Dispose( disposing );
} #region 组件设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器
/// 修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
}
#endregion protected override void OnPaint(PaintEventArgs pe)
{
pe.Graphics.DrawLine(new Pen(Color.Blue),0,4,80,5);
}
private void OnMouseEnter(object o,System.EventArgs e)
{
OnPaint(new PaintEventArgs(this.CreateGraphics(),this.ClientRectangle)); }
}
}