Delphi DBGridEH中,选中行、列、单元格

// 新增行后,默认首列

procedure TForm1.ADOQuery1AfterInsert(DataSet: TDataSet);
begin
  with DBGridEh1 do
  begin
    SelectedIndex := 0;
  end;
end;


// 行选中

DBGridEh_Yingfu_SearchQK.SelectedRows.SetCurrentRowSelected(True);


//选中单元格

DBGridEh1.SelectedField := ADOQuery1.FieldByName('收银简称');


//

  with DbgridEh_Xiaoshth_mx.SelectedField do
    if DATASET.Active then
      else if (FieldName = 'peij_dj') then //焦点停留在单价上
      begin
        Action_Searchprice.Execute;
      end

// 下拉框

    with DbgridEh_Xiaoshth_mx, DataSource.DataSet do
    begin
      SelectedField := FieldByName('cangk_dm');
      with dm_main.Query_Cangk do
      begin
        if active then close;
        open;
        first;
        Columns[SelectedIndex].KeyList.Clear;
        Columns[SelectedIndex].picklist.Clear;
        while not eof do
        begin
          Columns[SelectedIndex].KeyList.Add(fieldbyname('cangk_dm').AsString);
          Columns[SelectedIndex].PickList.Add(fieldbyname('cangk_mc').AsString);
          next;
        end;
      end;
      columns[SelectedIndex].autodropdown := true;
    end;

    with DbgridEh_Xiaoshth_mx, DataSource.DataSet do
    begin
      SelectedField := FieldByName('peij_dw');
      Columns[SelectedIndex].PickList := ReturnItemString(ITDanw_lc);
      columns[SelectedIndex].autodropdown := true;
      SelectedField := FieldByName('peij_jk');
      with Columns[SelectedIndex].PickList do
      begin
        Clear;
        Add('国产');
        ADd('进口');
        add('');
      end;
      Columns[SelectedIndex].AutoDropDown := true;
    end;

©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页