Infragistics UltraWinGrid (Win 9.1 버전)를 사용하고 있습니다. 기본 동작은 사용자가 텍스트를 셀에 입력 할 수있게하는 것입니다. Excel 스프레드 시트에서 여러 셀을 복사하면 첫 번째 셀의 데이터 만 UltraWinGrid에 붙여 넣습니다.Infragistics UltraWinGrid에서 키 누르기를 복사하여 붙여 넣기로 에뮬레이트 할 수 있습니까?
UltraWinGrid 셀을 편집 할 수 없게 설정하여 여러 셀을 붙여 넣기하는 동작을 쉽게 변경할 수 있습니다. CellClickAction.CellSelect; 불행히도 이렇게하면 데이터를 셀에 입력 할 수 없습니다.
그래서 이러한 설정을 InitializeLayout, KeyDown 및 KeyPress 이벤트로 수정하려고 시도했습니다.
private void ugridQuoteSheet_InitializeLayout(object sender, InitializeLayoutEventArgs e)
{
e.Layout.Override.AllowMultiCellOperations = AllowMultiCellOperation.All;
e.Layout.Override.CellClickAction = CellClickAction.CellSelect;
}
//Event used to circumvent the control key from choking in
//the KeyPress event. This doesn't work btw.
private void ugridQuoteSheet_KeyDown(object sender, KeyEventArgs e)
{
UltraGrid grid = (UltraGrid)sender;
if (e.Control == true)
{
e.SuppressKeyPress = true;
}
}
// This event comes after the KeyDown event. I made a lame attempt to stop
// the control button with (e.KeyChar != 22). I lifted some of this from
// the Infragistics post: http://forums.infragistics.com/forums/p/23690/86732.aspx#86732
private void ugridQuoteSheet_KeyPress(object sender, KeyPressEventArgs e)
{
UltraGrid grid = (UltraGrid)sender;
if ((grid != null) && (grid.ActiveCell != null) && (!grid.ActiveCell.IsInEditMode) && (e.KeyChar != 22))
{
grid.PerformAction(UltraGridAction.EnterEditMode);
EditorWithText editor = (EditorWithText)grid.ActiveCell.EditorResolved;
editor.TextBox.Text = e.KeyChar.ToString();
editor.TextBox.SelectionStart = 1;
}
}
// This puts the grid in CellSelect mode again so I won't edit text.
private void ugridQuoteSheet_AfterCellUpdate(object sender, CellEventArgs e)
{
this.ugridQuoteSheet.DisplayLayout.Override.CellClickAction = CellClickAction.CellSelect;
}
이제 셀에 값을 다시 입력 할 수 있습니다. 문제는 붙여 넣기를 위해 [Ctrl] [V]를 누를 때 KeyPressEventArgs.KeyChar가 22이고 'v'가 없다는 것입니다. ugridQuoteSheet_KeyPress 대리자에서이 문제를 우회하는 내 쓸데없는 시도를 볼 수 있습니다. 복사 및 붙여 넣기와 UltraWinGrid의 셀에 입력 할 수 있도록 이벤트 처리 및 CellClickAction 설정의 올바른 조합은 무엇입니까?