[]
You can use the default touch menu bar or touch strip to cut, copy, and paste cells. You can also customize the touch strip to provide additional options.
Tap a selected range to display the touch menu bar strip.
You can use the TouchStripOpening event to display a customized touch strip. You can also add menu items to the touch strip.
You can add a drop-down menu item with following code. This example also hides the "Cut" option in the touch strip.
Create a customized touch strip item.
Create and add a menu item
Add the new items to the touch strip.
Cancel the default touch strip in the TouchStripOpening event.
private FarPoint.Win.Spread.CellTouchStrip touchStripwithdropdownmenu;
private void Form1_Load(object sender, EventArgs e)
{
// Remove Cut from default touch menu bar
touchStripwithdropdownmenu = new FarPoint.Win.Spread.CellTouchStrip(this.fpSpread1);
touchStripwithdropdownmenu.Items["Cut"].Visible = false;
ToolStripSeparator separator1 = new ToolStripSeparator();
// Add AutoFill to touch menu bar
FarPoint.Win.Spread.TouchStripButton autoFill2 = new FarPoint.Win.Spread.TouchStripButton("AutoFill", Properties.Resources.AutoFill);
autoFill2.Click += autoFill_Click;
ToolStripSeparator separator2 = new ToolStripSeparator();
// Add drop down menu to touch menu bar
ToolStripDropDownButton dropDownMenu = new ToolStripDropDownButton(Properties.Resources.TouchMenuItemDownArrow);
dropDownMenu.ShowDropDownArrow = false;
dropDownMenu.ImageScaling = ToolStripItemImageScaling.None;
ContextMenuStrip menu = new System.Windows.Forms.ContextMenuStrip();
ToolStripMenuItem newcontitem1 = new ToolStripMenuItem();
newcontitem1.Text = "Copy";
newcontitem1.Click += newcontitem1_Click;
newcontitem1.AutoSize = false;
newcontitem1.Height = 30;
newcontitem1.Width = 100;
newcontitem1.TextAlign = ContentAlignment.MiddleLeft;
menu.Items.Add(newcontitem1);
ToolStripMenuItem newcontitem2 = new ToolStripMenuItem();
newcontitem2.Text = "Paste";
newcontitem2.Click += newcontitem2_Click;
newcontitem2.AutoSize = false;
newcontitem2.Height = 30;
newcontitem2.Width = 100;
newcontitem2.TextAlign = ContentAlignment.MiddleLeft;
menu.Items.Add(newcontitem2);
ToolStripMenuItem newcontitem3 = new ToolStripMenuItem();
newcontitem3.Text = "Clear";
newcontitem3.Click += newcontitem3_Click;
newcontitem3.AutoSize = false;
newcontitem3.Height = 30;
newcontitem3.Width = 100;
newcontitem3.TextAlign = ContentAlignment.MiddleLeft;
menu.Items.Add(newcontitem3);
dropDownMenu.DropDown = menu;
touchStripwithdropdownmenu.Items.AddRange(new ToolStripItem[] { separator1, autoFill2, separator2, dropDownMenu });
// Enable AutoFill
fpSpread1.AllowDragFill = true;
}
void autoFill_Click(object sender, EventArgs e)
{
FarPoint.Win.Spread.SpreadView activeView = fpSpread1.GetRootWorkbook().GetActiveWorkbook();
if (activeView != null)
{
activeView.ShowAutoFillIndicator();
}
}
void newcontitem1_Click(object sender, EventArgs e)
{
// Copy
fpSpread1.ActiveSheet.ClipboardCopy();
}
void newcontitem2_Click(object sender, EventArgs e)
{
// Paste
fpSpread1.ActiveSheet.ClipboardPaste(FarPoint.Win.Spread.ClipboardPasteOptions.Values);
}
void newcontitem3_Click(object sender, EventArgs e)
{
// Clear
int r1 = fpSpread1.ActiveSheet.Models.Selection.AnchorRow;
int c1 = fpSpread1.ActiveSheet.Models.Selection.AnchorColumn;
int r2 = fpSpread1.ActiveSheet.Models.Selection.LeadRow - r1 + 1;
int c2 = fpSpread1.ActiveSheet.Models.Selection.LeadColumn - c1 + 1;
FarPoint.Win.Spread.Model.DefaultSheetDataModel dataModel = (FarPoint.Win.Spread.Model.DefaultSheetDataModel)fpSpread1.ActiveSheet.Models.Data;
dataModel.ClearData(r1, c1, r2, c2);
}
void fpSpread1_TouchStripOpening(object sender, FarPoint.Win.Spread.TouchStripOpeningEventArgs e)
{
// Hide default touch menu bar
e.Cancel = true;
// Show customized touch menu bar
touchStripwithdropdownmenu.Show(new Point(e.X - 20, e.Y - 35 - touchStripwithdropdownmenu.Height));
}
Private touchStripwithdropdownmenu As FarPoint.Win.Spread.CellTouchStrip
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
' Remove Cut from default touch menu bar
touchStripwithdropdownmenu = New FarPoint.Win.Spread.CellTouchStrip(Me.FpSpread1)
touchStripwithdropdownmenu.Items("Cut").Visible = False
Dim separator1 As New ToolStripSeparator()
' Add AutoFill to touch menu bar
Dim autoFill2 As New FarPoint.Win.Spread.TouchStripButton("AutoFill", My.Resources.AutoFill)
AddHandler autoFill2.Click, AddressOf autoFill_Click
Dim separator2 As New ToolStripSeparator()
' Add drop down menu to touch menu bar
Dim dropDownMenu As New ToolStripDropDownButton(My.Resources.Resources.TouchMenuItemDownArrow)
dropDownMenu.ShowDropDownArrow = False
dropDownMenu.ImageScaling = ToolStripItemImageScaling.None
Dim menu As ContextMenuStrip = New System.Windows.Forms.ContextMenuStrip()
Dim newcontitem1 As New ToolStripMenuItem()
newcontitem1.Text = "Copy"
AddHandler newcontitem1.Click, AddressOf newcontitem1_Click
newcontitem1.AutoSize = False
newcontitem1.Height = 30
newcontitem1.Width = 100
newcontitem1.TextAlign = ContentAlignment.MiddleLeft
menu.Items.Add(newcontitem1)
Dim newcontitem2 As New ToolStripMenuItem()
newcontitem2.Text = "Paste"
AddHandler newcontitem2.Click, AddressOf newcontitem2_Click
newcontitem2.AutoSize = False
newcontitem2.Height = 30
newcontitem2.Width = 100
newcontitem2.TextAlign = ContentAlignment.MiddleLeft
menu.Items.Add(newcontitem2)
Dim newcontitem3 As New ToolStripMenuItem()
newcontitem3.Text = "Clear"
AddHandler newcontitem3.Click, AddressOf newcontitem3_Click
newcontitem3.AutoSize = False
newcontitem3.Height = 30
newcontitem3.Width = 100
newcontitem3.TextAlign = ContentAlignment.MiddleLeft
menu.Items.Add(newcontitem3)
dropDownMenu.DropDown = menu
touchStripwithdropdownmenu.Items.AddRange(New ToolStripItem() {separator1, autoFill2, separator2, dropDownMenu})
' Enable AutoFill
FpSpread1.AllowDragFill = True
End Sub
Private Sub autoFill_Click(sender As Object, e As EventArgs)
Dim activeView As FarPoint.Win.Spread.SpreadView = fpSpread1.GetRootWorkbook().GetActiveWorkbook()
If activeView IsNot Nothing Then
activeView.ShowAutoFillIndicator()
End If
End Sub
Private Sub newcontitem1_Click(sender As Object, e As EventArgs)
' Copy
fpSpread1.ActiveSheet.ClipboardCopy()
End Sub
Private Sub newcontitem2_Click(sender As Object, e As EventArgs)
' Paste
fpSpread1.ActiveSheet.ClipboardPaste(FarPoint.Win.Spread.ClipboardPasteOptions.Values)
End Sub
Private Sub newcontitem3_Click(sender As Object, e As EventArgs)
' Clear
Dim r1 As Integer = fpSpread1.ActiveSheet.Models.Selection.AnchorRow
Dim c1 As Integer = fpSpread1.ActiveSheet.Models.Selection.AnchorColumn
Dim r2 As Integer = fpSpread1.ActiveSheet.Models.Selection.LeadRow - r1 + 1
Dim c2 As Integer = fpSpread1.ActiveSheet.Models.Selection.LeadColumn - c1 + 1
Dim dataModel As FarPoint.Win.Spread.Model.DefaultSheetDataModel = DirectCast(fpSpread1.ActiveSheet.Models.Data, FarPoint.Win.Spread.Model.DefaultSheetDataModel)
dataModel.ClearData(r1, c1, r2, c2)
End Sub
Private Sub FpSpread1_TouchStripOpening(sender As Object, e As FarPoint.Win.Spread.TouchStripOpeningEventArgs) Handles FpSpread1.TouchStripOpening
' Hide default touch menu bar
e.Cancel = True
' Show customized touch menu bar
touchStripwithdropdownmenu.Show(New Point(e.X - 20, e.Y - 35 - touchStripwithdropdownmenu.Height))
End Sub
Touch Support with the Component