.NET 學習

.NET 學習生活感想... 万事成蹉跎..... 贵在坚持 及时整理自己做过和学过的东西

博客园 首页 新随笔 联系 订阅 管理

 

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

 

posted on 2011-05-17 13:18  Tonyyang  阅读(560)  评论(0编辑  收藏  举报
欢迎转载,转载请注明出处:http://www.cnblogs.com/Tonyyang/