AddControl 支持,这个不能像图表一样浮动着移动,是在固定位置的
- public class SpreadTextBox : TextBox, FarPoint.Win.Spread.DrawingSpace.IEmbeddedControlSupport
- {
- private FarPoint.Win.Spread.DrawingSpace.Moving moving = Moving.None;
- private FarPoint.Win.Spread.DrawingSpace.Sizing sizing = Sizing.None;
- private FarPoint.Win.Spread.DrawingSpace.ChildActivationPolicy activation = ChildActivationPolicy.DoubleClick;
- public virtual FarPoint.Win.Spread.DrawingSpace.ChildActivationPolicy ActivationPolicy {
- get {
- return activation;
- }
- set {
- }
- }
- public virtual FarPoint.Win.Spread.DrawingSpace.Moving CanMove {
- get {
- return moving;
- }
- set {
- moving = value;
- }
- }
- public virtual FarPoint.Win.Spread.DrawingSpace.Sizing CanSize {
- get {
- return sizing;
- }
- set {
- sizing = value;
- }
- }
- public void ControlPaint(Graphics g, Rectangle r, FarPoint.Win.Spread.Appearance appearance, object value, bool isSelected,
- bool isLocked, float zoomFactor)
- {
- g.SetClip(r, CombineMode.Intersect);
- g.FillRectangle(new SolidBrush(this.BackColor), r);
- g.DrawString(this.Text, Font, new SolidBrush(this.ForeColor), r.X, r.Y);
- this.TextChanged += new EventHandler(MeTextChanged);
- }
- public void MeTextChanged(object sender, EventArgs e)
- {
- this.BackColor = Color.Beige;
- }
- }
- SpreadTextBox tb = new SpreadTextBox();
- tb.Name = "TB";
- fpSpread1.ActiveSheet.AddControl(tb, 2, 2);
复制代码 |