就是打开数据源后,cxGrid正常显示数据后,想焦点在指定某的一列的第一行,回车后就在同一列往下一行移动。不知道这要怎么做!
请高手不吝赐教!
谢谢!

解决方案 »

  1.   

    在TableView Object Inspector中, 把OptionBehavior的
    FocusCellOnCycle, FocusCellOnTab, FocusFirstCellOnNewRecord,
    GoToNextCellOnEnter都设为True. 如果要位用
    DBTableView.DataController.FocusedRowIndex, 
    DBTableView.DataController.FocusedRecordIndex.
      

  2.   

    创意、自由、灵活,独特的双数据源连接,全功能的表格组件,
    超强的报表功能,适用于所有开发工具。http://www.anylib.com
      

  3.   

    dbgrideh有写过,在OnKeyDown里面写事件可以实现,楼主用的没用过~~~嘿嘿
      

  4.   

    某一列的第一行 是什么意思: 某一行的第1列吧.把TableViewprocedure TForm1.cxGrid1DBTableView1EditKeyDown(Sender: TcxCustomGridTableView;
      AItem: TcxCustomGridTableItem; AEdit: TcxCustomEdit; var Key: Word;
      Shift: TShiftState);
    begin
      if Sender.DataController.IsEOF then
        Sender.DataController.GotoFirst;
      if Key = VK_Return then begin
        Key := VK_Down;
      end;
    end;procedure TForm1.FormCreate(Sender: TObject);
    begin
      cxGrid1DBTableView1.DataController.FocusedRowIndex := 1;
      cxGrid1DBTableView1.OptionsBehavior.AlwaysShowEditor := true;
    end;
      

  5.   

    处理一下EditKeyDown(显示内置编辑器时)和KeyDown(未显示内置编辑器时)事件,
    没什么特别难的地方procedure TFormItemList.tvResultEditKeyDown(Sender: TcxCustomGridTableView;
      AItem: TcxCustomGridTableItem; AEdit: TcxCustomEdit; var Key: Word;
      Shift: TShiftState);
    begin
      if Key = VK_Return then
      begin
        if not Sender.DataController.IsEOF then
        begin
          Sender.DataController.GotoNext;
          Sender.Controller.EditingController.ShowEdit();
        end;
        Key := 0;
      end;
    end;procedure TFormItemList.tvResultKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    begin
      if Key = VK_Return then
      begin
        if not (Sender as TcxGridSite).GridView.DataController.IsEOF then
          (Sender as TcxGridSite).GridView.DataController.GotoNext;
        Key := 0;
      end;
    end;//判断当前cxGrid是否有焦点
    function IsGridFocused: Boolean;
    var
      AContainer: TcxCustomEdit;
    begin
      Result := Screen.ActiveControl is TcxGridSite;
      if not Result then
      begin
        AContainer := nil;
        if Screen.ActiveControl is TcxCustomEdit then
        begin
          AContainer := TcxCustomEdit(Screen.ActiveControl);
          Result := True;
        end
        else
          if (Screen.ActiveControl.Parent <> nil) and
            (Screen.ActiveControl.Parent is TcxCustomEdit) then
          begin
            AContainer := TcxCustomEdit(Screen.ActiveControl.Parent);
            Result := True;
          end;
        Result := Result and (AContainer.Parent is TcxGridSite);
      end;
    end;
      

  6.   

    对了还要把GoToNextCellOnEnter设为false
    TableView.OptionBehavior.GoToNextCellOnEnter := false;
      

  7.   

    TableView.Controller.FocusedItem := TableView.VisibleItems[1];
    //TableView.Controller.FocusedItem := TableView.GetColumnByFieldName("字段名");