///
<summary>
/// 首行新增,按ENTER,Focused NewItemRow
/// Tonyyang
/// 2011-05-18
/// </summary>
public class FocusedNewItemRowListViewControler : ViewController
{
public FocusedNewItemRowListViewControler()
{
// InitializeComponent();
// RegisterActions(components);
this .TargetViewType = ViewType.ListView;
this .Activated += new System.EventHandler( this .GridFormattingController_Activated);
}
private void GridFormattingController_Activated( object sender, EventArgs e)
{
View.ControlsCreated += View_ControlsCreated;
}
private void View_ControlsCreated( object sender, EventArgs e)
{
GridListEditor listEditor = ((DevExpress.ExpressApp.ListView)View).Editor as GridListEditor;
if (listEditor != null )
{
GridControl gridControl = (GridControl)listEditor.Control;
gridControl.ProcessGridKey += gridControl_ProcessGridKey;
}
}
void gridControl_ProcessGridKey( object sender, System.Windows.Forms.KeyEventArgs e)
{
GridControl gridControl = (GridControl)sender;
GridView view = gridControl.MainView as GridView;
if (e.KeyData == Keys.Enter && view.FocusedColumn == view.VisibleColumns[ 0 ])
{
view.FocusedRowHandle = GridControl.NewItemRowHandle;
// view.FocusedColumn = view.FocusedColumn;
// view.ShowEditor();
// e.Handled = true;
}
}
}
/// 首行新增,按ENTER,Focused NewItemRow
/// Tonyyang
/// 2011-05-18
/// </summary>
public class FocusedNewItemRowListViewControler : ViewController
{
public FocusedNewItemRowListViewControler()
{
// InitializeComponent();
// RegisterActions(components);
this .TargetViewType = ViewType.ListView;
this .Activated += new System.EventHandler( this .GridFormattingController_Activated);
}
private void GridFormattingController_Activated( object sender, EventArgs e)
{
View.ControlsCreated += View_ControlsCreated;
}
private void View_ControlsCreated( object sender, EventArgs e)
{
GridListEditor listEditor = ((DevExpress.ExpressApp.ListView)View).Editor as GridListEditor;
if (listEditor != null )
{
GridControl gridControl = (GridControl)listEditor.Control;
gridControl.ProcessGridKey += gridControl_ProcessGridKey;
}
}
void gridControl_ProcessGridKey( object sender, System.Windows.Forms.KeyEventArgs e)
{
GridControl gridControl = (GridControl)sender;
GridView view = gridControl.MainView as GridView;
if (e.KeyData == Keys.Enter && view.FocusedColumn == view.VisibleColumns[ 0 ])
{
view.FocusedRowHandle = GridControl.NewItemRowHandle;
// view.FocusedColumn = view.FocusedColumn;
// view.ShowEditor();
// e.Handled = true;
}
}
}