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;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值