作成日: 2022/03/11 最終更新日: 2022/03/30
文書種別
使用方法
詳細
編集時のキャレットの位置は、編集用コントロールのSelectionStartプロパティに任意の値を設定することで変更可能です。
下記のサンプルコードは整数1桁から編集開始する例です。
[Visual Basic]
[C#]
下記のサンプルコードは整数1桁から編集開始する例です。
[Visual Basic]
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
' MultiRowの設定
Dim gcNumber As New GcNumberCell()
GcMultiRow1.Template = Template.CreateGridTemplate(New Cell() {gcNumber})
GcMultiRow1.RowCount = 5
' テストデータの設定
GcMultiRow1.SetValue(0, 0, 12345)
GcMultiRow1.SetValue(1, 0, 1.2345)
GcMultiRow1.SetValue(2, 0, 12.345)
GcMultiRow1.SetValue(3, 0, 123.45)
GcMultiRow1.SetValue(4, 0, 1234.5)
End Sub
Private Sub GcMultiRow1_EditingControlShowing(sender As Object, e As EditingControlShowingEventArgs) Handles GcMultiRow1.EditingControlShowing
If TypeOf e.Control Is GcNumberEditingControl Then
Dim editor As GcNumberEditingControl = GcMultiRow1.EditingControl
' キャレットを小数点の直前に配置
If editor.Text.IndexOf(".") < 0 Then Exit Sub
editor.SelectionStart = editor.Text.IndexOf(".")
End If
End Sub
[C#]
private void Form1_Load(object sender, EventArgs e)
{
// MultiRowの設定
GcNumberCell gcNumber = new GcNumberCell();
gcMultiRow1.Template = GrapeCity.Win.MultiRow.Template.CreateGridTemplate(new Cell[] { gcNumber });
gcMultiRow1.RowCount = 5;
// テストデータの設定
gcMultiRow1.SetValue(0, 0, 12345);
gcMultiRow1.SetValue(1, 0, 1.2345);
gcMultiRow1.SetValue(2, 0, 12.345);
gcMultiRow1.SetValue(3, 0, 123.45);
gcMultiRow1.SetValue(4, 0, 1234.5);
}
private void GcMultiRow1_EditingControlShowing1(object sender, EditingControlShowingEventArgs e)
{
if (e.Control is GcNumberEditingControl)
{
GcNumberEditingControl editor = (GcNumberEditingControl)gcMultiRow1.EditingControl;
// キャレットを小数点の直前に配置
if (editor.Text.IndexOf(".") < 0) { return; }
editor.SelectionStart = editor.Text.IndexOf(".");
}
}