本文介绍了Devexpress存储库ComboBoxEdit放弃光标位置。 Edit.SelectionStart未分配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在网格控件中遇到了一个与我的comboBoxEdit有关的问题。我使用Winforms Devepress 11.2。我点击了现有存储库comboBoxEdit的文本,并输入出现在后面,但是它显示为sdrawkcab raeppa,就像在镜像中一样。

有一些关于这个主题的帖子,没有一个解决方案似乎不起作用



原因是以下

  foreach(this.gvNotes.Columns中的GridColumn列)
{
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
有没有人知道什么事件需要处理以不松动光标位置?

解决方案

这是我做的,似乎设置了插入位置



global:private int carretPosition = 0;

  editvaluechanged处理程序

SaveCaretPosition(editValue.ToString()。
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;
}


I am having an issue with my comboBoxEdit in a gridcontrol. I am using Winforms Devepress 11.2. I clicked in the text of an existing Repository comboBoxEdit, and typed in "appear backwards", however, it displayed as "sdrawkcab raeppa" like it would in a mirror.
There are some posts about this topic but none of the solutions seem to work

The reason for this is the following

 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();

        }

This PostEditor ensures the save button is enabled when the user is still in the current cell. The user does not need to leave the cell or change column for the changes to be posted to the grid.

So this is what I did:

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;

            }

This did not solve the problem of the cursor resetting to the start position. Edit.SelectionStart is not being assinged to the len value.Even though len changes to 1 edit.SelectionStart remains at 0Does anyone know what event needs to be handled to not loose the cursor position?

解决方案

This is what I did and seemed to set the caret position

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;
        }

这篇关于Devexpress存储库ComboBoxEdit放弃光标位置。 Edit.SelectionStart未分配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 07:15