作成日: 2024/01/31 最終更新日: 2024/01/31
文書種別
使用方法
詳細
CellValidatingイベントでSelectAllメソッドを使用ことで実現することが可能です。
[Visual Basic]
[C#]
[Visual Basic]
Imports GrapeCity.Win.MultiRow Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load GcMultiRow1.Template = Template.CreateGridTemplate(2) GcMultiRow1.RowCount = 5 End Sub Private Sub GcMultiRow1_CellValidating(sender As Object, e As GrapeCity.Win.MultiRow.CellValidatingEventArgs) Handles GcMultiRow1.CellValidating ' 現在のセルの値が"abc"の場合、文字を全選択する If Not e.FormattedValue Is Nothing Then Dim data As String = e.FormattedValue.ToString() If data = "abc" Then e.Cancel = True DirectCast(GcMultiRow1.EditingControl, TextBoxEditingControl).SelectAll() End If End If End Sub
[C#]
using GrapeCity.Win.MultiRow;
private void Form1_Load(object sender, EventArgs e)
{
gcMultiRow1.Template = Template.CreateGridTemplate(2);
gcMultiRow1.RowCount = 5;
}
private void gcMultiRow1_CellValidating(object sender, CellValidatingEventArgs e)
{
// 現在のセルの値が"abc"の場合、文字を全選択する
{
if ((e.FormattedValue != null))
{
string data = e.FormattedValue.ToString();
if (data == "abc")
{
e.Cancel = true;
(gcMultiRow1.EditingControl as TextBoxEditingControl).SelectAll();
}
}
}
}