Spread Windows Forms 10.0 Product Documentation
AcceptsArrowKeys Property (EditBaseCellType)
Example 


Gets or sets how arrow keys are processed by the edit control.
Syntax
'Declaration
 
Public Property AcceptsArrowKeys As AcceptsArrowKeys
'Usage
 
Dim instance As EditBaseCellType
Dim value As AcceptsArrowKeys
 
instance.AcceptsArrowKeys = value
 
value = instance.AcceptsArrowKeys
public AcceptsArrowKeys AcceptsArrowKeys {get; set;}

Property Value

AcceptsArrowKeys setting that determines how arrow keys are processed
Example
This example sets several properties of the cell type including how arrow keys are processed by the edit cell, the background image to display, whether ellipsis characters are displayed for text that is too long to fit in the cell, the subeditor to display if the user double-clicks in the cell while in edit mode, the orientation of the text and whether the text wraps if it is too long to fit in the cell.
public class se : Form, FarPoint.Win.Spread.CellType.ISubEditor
{
   public event EventHandler ValueChanged;
   public event EventHandler CloseUp;
   private TextBox txt = null;
   private Button BtnOk = null;
   private Button BtnCancel = null;

   public se()
   {
      FormBorderStyle = FormBorderStyle.FixedSingle;
      MaximizeBox = false;
      MinimizeBox = false;
      ControlBox = false;
      txt = new TextBox();
      BtnOk = new Button();
      BtnCancel = new Button();
      txt.Location = new Point(0, 0);
      txt.Size = new Size(110, 200);
      txt.ForeColor = Color.Red;
      BtnOk.Location = new Point(3, 75);
      BtnOk.Size = new Size(50, 25);
      BtnOk.Text = "OK";
      BtnOk.ForeColor = Color.Red;
      BtnCancel.Location = new Point(57, 75);
      BtnCancel.Size = new Size(50, 25);
      BtnCancel.Text = "Cancel";
      BtnCancel.ForeColor = Color.Red;
      Controls.Add(txt);
      Controls.Add(BtnOk);
      Controls.Add(BtnCancel);
      Text = "Editor";
      BtnOk.Click += new EventHandler(OK_Clicked);
      BtnCancel.Click += new EventHandler(Cancel_Clicked);
      txt.TextChanged += new EventHandler(txt_TextChanged);
   }

   private void OK_Clicked(object sender, EventArgs e)
   {
      if (ValueChanged != null)
         ValueChanged(this, EventArgs.Empty);
      if (CloseUp != null)
         CloseUp(this, EventArgs.Empty);
   }

   private void Cancel_Clicked(object sender, EventArgs e)
   {
      if (CloseUp != null)
         CloseUp(this, EventArgs.Empty);
   }

   private void txt_TextChanged(object sender, EventArgs e)
   {
      Text = txt.Text;
   }

   public Point GetLocation(Rectangle rect)
   {
      Point pt = new Point(0);
      Size sz = GetPreferredSize();
      pt.Y = (Screen.PrimaryScreen.WorkingArea.Height/2) - (sz.Height/2);
      pt.X = (Screen.PrimaryScreen.WorkingArea.Width/2) - (sz.Width/2);
      return pt;
   }

   public Control GetSubEditorControl()
   {
      return this;
   }

   public object GetValue()
   {
      return txt.Text;
   }

   public void SetValue(object value)
   {
      value = txt.Text;
   }

   public Size GetPreferredSize()
   {
      return new Size(115, 130);
   }
}

FarPoint.Win.Spread.CellType.EditBaseCellType ed = new FarPoint.Win.Spread.CellType.EditBaseCellType();
fpSpread1.ActiveSheet.Cells[0, 0].Text = "I am an EditBaseCellType";
ed.AcceptsArrowKeys = FarPoint.Win.SuperEdit.AcceptsArrowKeys.None;
ed.BackgroundImage = new FarPoint.Win.Picture(Image.FromFile(Application.StartupPath + "\\Trffc14.ico"));
ed.StringTrim = StringTrimming.EllipsisCharacter;
ed.SubEditor = new se();
ed.TextOrientation = FarPoint.Win.TextOrientation.TextHorizontal;
ed.WordWrap = false;
fpSpread1.ActiveSheet.Cells[0, 0].CellType = ed;
Public Class se
Inherits Form
Implements FarPoint.Win.Spread.CellType.ISubEditor

Public Event CloseUp(ByVal sender As Object, ByVal e As EventArgs) Implements FarPoint.Win.Spread.CellType.ISubEditor.CloseUp
Public Event ValueChanged(ByVal sender As Object, ByVal e As EventArgs) Implements FarPoint.Win.Spread.CellType.ISubEditor.ValueChanged
Private BtnOk As Button = Nothing
Private BtnCancel As Button = Nothing
Private txt As TextBox = Nothing

Public Sub New()
   FormBorderStyle = FormBorderStyle.FixedSingle
   MaximizeBox = False
   MinimizeBox = False
   ControlBox = False
   txt = New TextBox()
   BtnOk = New Button()
   BtnCancel = New Button()
   txt.Location = New Point(0, 0)
   txt.Size = New Size(110, 200)
   txt.ForeColor = Color.Red
   BtnOk.Location = New Point(3, 75)
   BtnOk.Size = New Size(50, 25)
   BtnOk.Text = "OK"
   BtnOk.ForeColor = Color.Red
   BtnCancel.Location = New Point(57, 75)
   BtnCancel.Size = New Size(50, 25)
   BtnCancel.Text = "Cancel"
   BtnCancel.ForeColor = Color.Red
   Controls.Add(txt)
   Controls.Add(BtnOk)
   Controls.Add(BtnCancel)
   Text = "Editor"
   AddHandler BtnOk.Click, AddressOf OK_Clicked
   AddHandler BtnCancel.Click, AddressOf Close_Clicked
   AddHandler txt.TextChanged, AddressOf txt_TextChanged
End Sub

Private Sub OK_Clicked(ByVal sender As Object, ByVal e As EventArgs)
   RaiseEvent ValueChanged(Me, EventArgs.Empty)
   RaiseEvent CloseUp(Me, EventArgs.Empty)
End Sub

Private Sub Close_Clicked(ByVal sender As Object, ByVal e As EventArgs)
   RaiseEvent CloseUp(Me, EventArgs.Empty)
End Sub

Private Sub txt_TextChanged(ByVal sender As Object, ByVal e As EventArgs)
   Text = txt.Text
End Sub

Public Function GetLocation(ByVal rect As Rectangle) As Point Implements FarPoint.Win.Spread.CellType.ISubEditor.GetLocation
   Dim pt As New Point(0)
   Dim sz As Size = GetPreferredSize()
   pt.Y = (Screen.PrimaryScreen.WorkingArea.Height / 2) - (sz.Height / 2)
   pt.X = (Screen.PrimaryScreen.WorkingArea.Width / 2) - (sz.Width / 2)
   Return pt
End Function

Public Function GetPreferredSize() As Size Implements FarPoint.Win.Spread.CellType.ISubEditor.GetPreferredSize
   Return New Size(115, 130)
End Function

Public Function GetSubEditorControl() As Control Implements FarPoint.Win.Spread.CellType.ISubEditor.GetSubEditorControl
   Return Me
End Function

Public Function GetValue() As Object Implements FarPoint.Win.Spread.CellType.ISubEditor.GetValue
   Return txt.Text
End Function

Public Sub SetValue(ByVal value As Object) Implements FarPoint.Win.Spread.CellType.ISubEditor.SetValue
   value = txt.Text
   End Sub
End Class

Dim ed As New FarPoint.Win.Spread.CellType.EditBaseCellType()
FpSpread1.ActiveSheet.Cells(0, 0).Text = "I am an EditBaseCellType"
ed.AcceptsArrowKeys = FarPoint.Win.SuperEdit.AcceptsArrowKeys.None
ed.BackgroundImage = New FarPoint.Win.Picture(Image.FromFile(Application.StartupPath & "\Trffc14.ico"))
ed.StringTrim = StringTrimming.EllipsisCharacter
ed.SubEditor = New se()
ed.TextOrientation = FarPoint.Win.TextOrientation.TextHorizontal
ed.WordWrap = False
FpSpread1.ActiveSheet.Cells(0, 0).CellType = ed
Requirements

Target Platforms: Windows 2000 Professional (SP4), Windows 2000 Server, Windows 2003 Server (SP1), Windows Server 2012 R2, Windows 2008, Windows XP (SP2), Windows Vista, Windows 7, Windows 8, Windows 8.1, Windows 10

See Also

Reference

EditBaseCellType Class
EditBaseCellType Members

 

 


Copyright © GrapeCity, inc. All rights reserved.