[Delete]キーでチャート/シェイプが削除される動作を抑制したい
対象製品
SPREAD for Windows Forms 8.0J
詳細
DialogKeyイベントを使用することで、[Delete]キー押下によるチャートおよびシェイプが削除される動作を抑止することができます。
◎サンプルコード(VB)
◎サンプルコード(C#)
◎サンプルコード(VB)
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' チャートの設定
Dim chart1 As New FarPoint.Win.Spread.Chart.SpreadChart()
chart1.ChartName = "chart1"
chart1.Size = New Size(200, 180)
chart1.Location = New Point(0, 0)
Dim Series = New FarPoint.Win.Chart.BarSeries()
Series.SeriesName = "Series 0"
Series.Values.Add(2.0)
Series.Values.Add(4.0)
Series.Values.Add(3.0)
Series.Values.Add(5.0)
Dim PlotArea = New FarPoint.Win.Chart.YPlotArea()
PlotArea.Location = New PointF(0.2F, 0.2F)
PlotArea.Size = New SizeF(0.6F, 0.6F)
PlotArea.Series.Add(Series)
Dim Model = New FarPoint.Win.Chart.ChartModel()
Model.PlotAreas.Add(PlotArea)
chart1.Model = Model
FpSpread1.ActiveSheet.Charts.Add(chart1)
' シェイプの設定
Dim arrow As New FarPoint.Win.Spread.DrawingSpace.ArrowShape
arrow.Name = "Arrow-01"
arrow.BackColor = Color.Red
arrow.AlphaBlendBackColor = 90
arrow.ShadowColor = Color.Blue
arrow.AlphaBlendShadowColor = 90
arrow.ShadowDirection = FarPoint.Win.Spread.DrawingSpace.ShadowDirection.BottomRight
arrow.SetBounds(10, 10, 90, 60)
FpSpread1.ActiveSheet.AddShape(arrow)
End Sub
Private Sub FpSpread1_DialogKey(ByVal sender As Object, ByVal e As FarPoint.Win.Spread.DialogKeyEventArgs) Handles FpSpread1.DialogKey
If (TypeOf FpSpread1.ActiveWindowlessObject Is FarPoint.Win.Spread.DrawingSpace.PSShape) AndAlso e.KeyData = Keys.Delete Then
e.Handled = True
End If
End Sub
' チャートの設定
Dim chart1 As New FarPoint.Win.Spread.Chart.SpreadChart()
chart1.ChartName = "chart1"
chart1.Size = New Size(200, 180)
chart1.Location = New Point(0, 0)
Dim Series = New FarPoint.Win.Chart.BarSeries()
Series.SeriesName = "Series 0"
Series.Values.Add(2.0)
Series.Values.Add(4.0)
Series.Values.Add(3.0)
Series.Values.Add(5.0)
Dim PlotArea = New FarPoint.Win.Chart.YPlotArea()
PlotArea.Location = New PointF(0.2F, 0.2F)
PlotArea.Size = New SizeF(0.6F, 0.6F)
PlotArea.Series.Add(Series)
Dim Model = New FarPoint.Win.Chart.ChartModel()
Model.PlotAreas.Add(PlotArea)
chart1.Model = Model
FpSpread1.ActiveSheet.Charts.Add(chart1)
' シェイプの設定
Dim arrow As New FarPoint.Win.Spread.DrawingSpace.ArrowShape
arrow.Name = "Arrow-01"
arrow.BackColor = Color.Red
arrow.AlphaBlendBackColor = 90
arrow.ShadowColor = Color.Blue
arrow.AlphaBlendShadowColor = 90
arrow.ShadowDirection = FarPoint.Win.Spread.DrawingSpace.ShadowDirection.BottomRight
arrow.SetBounds(10, 10, 90, 60)
FpSpread1.ActiveSheet.AddShape(arrow)
End Sub
Private Sub FpSpread1_DialogKey(ByVal sender As Object, ByVal e As FarPoint.Win.Spread.DialogKeyEventArgs) Handles FpSpread1.DialogKey
If (TypeOf FpSpread1.ActiveWindowlessObject Is FarPoint.Win.Spread.DrawingSpace.PSShape) AndAlso e.KeyData = Keys.Delete Then
e.Handled = True
End If
End Sub
◎サンプルコード(C#)
private void Form1_Load(object sender, EventArgs e)
{
// チャートの設定
FarPoint.Win.Spread.Chart.SpreadChart chart1 = new FarPoint.Win.Spread.Chart.SpreadChart();
chart1.ChartName = "chart1";
chart1.Size = new Size(200, 180);
chart1.Location = new Point(0, 0);
FarPoint.Win.Chart.BarSeries Series = new FarPoint.Win.Chart.BarSeries();
Series.SeriesName = "Series 0";
Series.Values.Add(2.0);
Series.Values.Add(4.0);
Series.Values.Add(3.0);
Series.Values.Add(5.0);
FarPoint.Win.Chart.YPlotArea PlotArea = new FarPoint.Win.Chart.YPlotArea();
PlotArea.Location = new PointF(0.2F, 0.2F);
PlotArea.Size = new SizeF(0.6F, 0.6F);
PlotArea.Series.Add(Series);
FarPoint.Win.Chart.ChartModel Model = new FarPoint.Win.Chart.ChartModel();
Model.PlotAreas.Add(PlotArea);
chart1.Model = Model;
fpSpread1.ActiveSheet.Charts.Add(chart1);
// シェイプの設定
FarPoint.Win.Spread.DrawingSpace.ArrowShape arrow = new FarPoint.Win.Spread.DrawingSpace.ArrowShape();
arrow.Name = "Arrow-01";
arrow.BackColor = Color.Red;
arrow.AlphaBlendBackColor = 90;
arrow.ShadowColor = Color.Blue;
arrow.AlphaBlendShadowColor = 90;
arrow.ShadowDirection = FarPoint.Win.Spread.DrawingSpace.ShadowDirection.BottomRight;
arrow.SetBounds(10, 10, 90, 60);
fpSpread1.ActiveSheet.AddShape(arrow);
}
void fpSpread1_DialogKey(object sender, FarPoint.Win.Spread.DialogKeyEventArgs e)
{
if ((fpSpread1.ActiveWindowlessObject is FarPoint.Win.Spread.DrawingSpace.PSShape) && e.KeyData == Keys.Delete)
{
e.Handled = true;
}
}
{
// チャートの設定
FarPoint.Win.Spread.Chart.SpreadChart chart1 = new FarPoint.Win.Spread.Chart.SpreadChart();
chart1.ChartName = "chart1";
chart1.Size = new Size(200, 180);
chart1.Location = new Point(0, 0);
FarPoint.Win.Chart.BarSeries Series = new FarPoint.Win.Chart.BarSeries();
Series.SeriesName = "Series 0";
Series.Values.Add(2.0);
Series.Values.Add(4.0);
Series.Values.Add(3.0);
Series.Values.Add(5.0);
FarPoint.Win.Chart.YPlotArea PlotArea = new FarPoint.Win.Chart.YPlotArea();
PlotArea.Location = new PointF(0.2F, 0.2F);
PlotArea.Size = new SizeF(0.6F, 0.6F);
PlotArea.Series.Add(Series);
FarPoint.Win.Chart.ChartModel Model = new FarPoint.Win.Chart.ChartModel();
Model.PlotAreas.Add(PlotArea);
chart1.Model = Model;
fpSpread1.ActiveSheet.Charts.Add(chart1);
// シェイプの設定
FarPoint.Win.Spread.DrawingSpace.ArrowShape arrow = new FarPoint.Win.Spread.DrawingSpace.ArrowShape();
arrow.Name = "Arrow-01";
arrow.BackColor = Color.Red;
arrow.AlphaBlendBackColor = 90;
arrow.ShadowColor = Color.Blue;
arrow.AlphaBlendShadowColor = 90;
arrow.ShadowDirection = FarPoint.Win.Spread.DrawingSpace.ShadowDirection.BottomRight;
arrow.SetBounds(10, 10, 90, 60);
fpSpread1.ActiveSheet.AddShape(arrow);
}
void fpSpread1_DialogKey(object sender, FarPoint.Win.Spread.DialogKeyEventArgs e)
{
if ((fpSpread1.ActiveWindowlessObject is FarPoint.Win.Spread.DrawingSpace.PSShape) && e.KeyData == Keys.Delete)
{
e.Handled = true;
}
}
キーワード
シェイプ チャート