我在网格控件中遇到了comboBoxEdit的问题。我正在使用Winforms Devepress 11.2。我点击了现有存储库comboBoxEdit的文本,然后键入"向后显示"但是,它显示为" sdrawkcab raeppa"就像在镜子里一样 有一些关于这个主题的帖子,但没有一个解决方案似乎有用
原因如下
foreach (GridColumn column in this.gvNotes.Columns)
{
var columnEdit = column.ColumnEdit;
if (columnEdit != null)
{
column.ColumnEdit.EditValueChanged += this.PostEditValueChanged;
}
}
private void PostEditValueChanged(object sender, EventArgs e)
{
this.gvNotes.PostEditor();
}
此PostEditor确保当用户仍在当前单元格中时启用保存按钮。用户无需离开单元格或更改列以将更改发布到网格中。
所以这就是我所做的:
private void PostEditValueChanged(object sender, EventArgs e)
{
ComboBoxEdit edit = this.gridNotes.FocusedView.ActiveEditor as ComboBoxEdit;
if (edit != null)
{
int len = edit.SelectionLength;
int start = edit.SelectionStart;
gridNotes.FocusedView.PostEditor();
edit.SelectionLength = len;
edit.SelectionStart = start;
}
这没有解决光标重置到起始位置的问题。 Edit.SelectionStart没有被赋予len值。即使len更改为1 edit.SelectionStart仍为0 有谁知道需要处理什么事件才能松开光标位置?
答案 0 :(得分:0)
这就是我所做的,似乎设置了插入位置
global:private int carretPosition = 0;
editvaluechanged handler
SaveCaretPosition(editValue.ToString().Length);
this.gridView1.PostEditor();
this.gridView1.ShowEditor();
this.SetCaretPosition(this.gridView1.ActiveEditor as DevExpress.XtraEditors.TextEdit);
private void SaveCaretPosition(int position)
{
carretPosition = position;
}
private void SetCaretPosition(TextEdit edit)
{
edit.SelectionStart = carretPosition;
}