Source/AdvTree/TextBoxEx.cs
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Drawing;
using System.Windows.Forms;
using System.ComponentModel;
namespace DevComponents.AdvTree
{
/// <summary>
/// Represents the text box for editing cell's text.
/// </summary>
[Designer(typeof(System.Windows.Forms.Design.ControlDesigner)),ToolboxItem(false)]
internal class TextBoxEx:TextBox, ICellEditControl
{
#region Private variables
private bool m_WordWrap=false;
#endregion
#region Events
public event EventHandler EditComplete;
public event EventHandler CancelEdit;
#endregion
#region Constructor
public TextBoxEx():base()
{
this.AutoSize=false;
this.BorderStyle=System.Windows.Forms.BorderStyle.None;
}
#endregion
#region Internal Implementation
protected override void OnKeyDown(KeyEventArgs e)
{
base.OnKeyDown(e);
if(e.KeyCode==Keys.Enter && !m_WordWrap || e.KeyCode==Keys.Enter && e.Modifiers==Keys.Control)
{
if(EditComplete!=null)
EditComplete(this, new EventArgs());
}
else if(e.KeyCode==Keys.Escape)
{
if(CancelEdit!=null)
CancelEdit(this,new EventArgs());
}
}
protected override void OnTextChanged(EventArgs e)
{
base.OnTextChanged (e);
ResizeControl();
}
private void ResizeControl()
{
Graphics g=this.CreateGraphics();
SizeF size=g.MeasureString(this.Text,this.Font);
int width=(int)Math.Ceiling(size.Width);
int height=(int)Math.Ceiling(size.Height);
if(this.Parent!=null && this.Right+(width-this.Width)>this.Parent.Right)
后面还有 64 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。