gridView設定游標輸入位置
阿新 • • 發佈:2019-02-09
/// <summary>
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void gridView1_CellValueChanging(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
{
//此句啟用gridView1_CellValueChanged()
gridView1.SetRowCellValue(e.RowHandle, e.Column, e.Value);
//設定游標插入符位置
GridView view = sender as GridView;
TextEdit textEdit = view.ActiveEditor as TextEdit;
if (textEdit == null) return;
textEdit.SelectionStart = textEdit.Text.Length;
textEdit.SelectionLength = textEdit.Text.Length;
textEdit.ScrollToCaret();
}
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void gridView1_CellValueChanging(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
{
//此句啟用gridView1_CellValueChanged()
gridView1.SetRowCellValue(e.RowHandle, e.Column, e.Value);
//設定游標插入符位置
GridView view = sender as GridView;
TextEdit textEdit = view.ActiveEditor as TextEdit;
if (textEdit == null) return;
textEdit.SelectionStart = textEdit.Text.Length;
textEdit.SelectionLength = textEdit.Text.Length;
textEdit.ScrollToCaret();
}