アクティブセルのセル型を判断するには?
対象製品
El Tabelle for .NET 3.0J
詳細
アクティブセルのセル型を判断するには、Visual Basic では TypeOf ~ Is キーワード、C# では as ~ != キーワードによる比較を行います。
WorkBook/Sheet の場合:
[Visual Basic]
[C#]
MultiRowSheet の場合:
[Visual Basic]
[C#]
WorkBook/Sheet の場合:
[Visual Basic]
If TypeOf Sheet1.ActiveCell.Editor Is _
GrapeCity.Win.ElTabelle.Editors.TextEditor Then
Debug.WriteLine("アクティブセルは文字列型です。")
ElseIf TypeOf Sheet1.ActiveCell.Editor _
Is GrapeCity.Win.ElTabelle.Editors.NumberEditor Then
Debug.WriteLine("アクティブセルは数値型です。")
ElseIf TypeOf Sheet1.ActiveCell.Editor _
Is GrapeCity.Win.ElTabelle.Editors.DateEditor Then
Debug.WriteLine("アクティブセルは日付型です。")
End If
GrapeCity.Win.ElTabelle.Editors.TextEditor Then
Debug.WriteLine("アクティブセルは文字列型です。")
ElseIf TypeOf Sheet1.ActiveCell.Editor _
Is GrapeCity.Win.ElTabelle.Editors.NumberEditor Then
Debug.WriteLine("アクティブセルは数値型です。")
ElseIf TypeOf Sheet1.ActiveCell.Editor _
Is GrapeCity.Win.ElTabelle.Editors.DateEditor Then
Debug.WriteLine("アクティブセルは日付型です。")
End If
[C#]
if((sheet1.ActiveCell.Editor as
GrapeCity.Win.ElTabelle.Editors.TextEditor) != null)
{
System.Diagnostics.Debug.WriteLine("アクティブセルは文字列型です。");
}
else if((sheet1.ActiveCell.Editor as
GrapeCity.Win.ElTabelle.Editors.NumberEditor) != null)
{
System.Diagnostics.Debug.WriteLine("アクティブセルは数値型です。");
}
else if((sheet1.ActiveCell.Editor as
GrapeCity.Win.ElTabelle.Editors.DateEditor) != null)
{
System.Diagnostics.Debug.WriteLine("アクティブセルは日付型です。");
}
GrapeCity.Win.ElTabelle.Editors.TextEditor) != null)
{
System.Diagnostics.Debug.WriteLine("アクティブセルは文字列型です。");
}
else if((sheet1.ActiveCell.Editor as
GrapeCity.Win.ElTabelle.Editors.NumberEditor) != null)
{
System.Diagnostics.Debug.WriteLine("アクティブセルは数値型です。");
}
else if((sheet1.ActiveCell.Editor as
GrapeCity.Win.ElTabelle.Editors.DateEditor) != null)
{
System.Diagnostics.Debug.WriteLine("アクティブセルは日付型です。");
}
MultiRowSheet の場合:
[Visual Basic]
If TypeOf MultiRowSheet1.ActiveCell.Editor Is _
GrapeCity.Win.ElTabelle.Editors.TextEditor Then
Debug.WriteLine("アクティブセルは文字列型です。")
ElseIf TypeOf MultiRowSheet1.ActiveCell.Editor _
Is GrapeCity.Win.ElTabelle.Editors.NumberEditor Then
Debug.WriteLine("アクティブセルは数値型です。")
ElseIf TypeOf MultiRowSheet1.ActiveCell.Editor _
Is GrapeCity.Win.ElTabelle.Editors.DateEditor Then
Debug.WriteLine("アクティブセルは日付型です。")
End If
GrapeCity.Win.ElTabelle.Editors.TextEditor Then
Debug.WriteLine("アクティブセルは文字列型です。")
ElseIf TypeOf MultiRowSheet1.ActiveCell.Editor _
Is GrapeCity.Win.ElTabelle.Editors.NumberEditor Then
Debug.WriteLine("アクティブセルは数値型です。")
ElseIf TypeOf MultiRowSheet1.ActiveCell.Editor _
Is GrapeCity.Win.ElTabelle.Editors.DateEditor Then
Debug.WriteLine("アクティブセルは日付型です。")
End If
[C#]
if((multiRowSheet1.ActiveCell.Editor as
GrapeCity.Win.ElTabelle.Editors.TextEditor) != null)
{
System.Diagnostics.Debug.WriteLine("アクティブセルは文字列型です。");
}
else if((multiRowSheet1.ActiveCell.Editor as
GrapeCity.Win.ElTabelle.Editors.NumberEditor) != null)
{
System.Diagnostics.Debug.WriteLine("アクティブセルは数値型です。");
}
else if((multiRowSheet1.ActiveCell.Editor as
GrapeCity.Win.ElTabelle.Editors.DateEditor) != null)
{
System.Diagnostics.Debug.WriteLine("アクティブセルは日付型です。");
}
GrapeCity.Win.ElTabelle.Editors.TextEditor) != null)
{
System.Diagnostics.Debug.WriteLine("アクティブセルは文字列型です。");
}
else if((multiRowSheet1.ActiveCell.Editor as
GrapeCity.Win.ElTabelle.Editors.NumberEditor) != null)
{
System.Diagnostics.Debug.WriteLine("アクティブセルは数値型です。");
}
else if((multiRowSheet1.ActiveCell.Editor as
GrapeCity.Win.ElTabelle.Editors.DateEditor) != null)
{
System.Diagnostics.Debug.WriteLine("アクティブセルは日付型です。");
}
キーワード
HowTo
この文書は、以前は次のFAQ IDで公開されていました : 6961