我在作DBGRID控件的单元格输入时,用到了列的buttonstyle:=cbsellips属性,想在oneditbuttonclick事件中根据输入的值模糊查询后弹出一个窗口让用户选择自己要输入的值!可DBGRID中好像没这个属性去取那个值!!!如何办??

解决方案 »

  1.   

    if DBGrid2.SelectedField.FieldName='ItemNo' thenif dbgrid2.SelectedField.Value='Y' thenif dbgrid2.SelectedField.Text='Y' then
      

  2.   

    假定你已经有了一个函数: function GetValueByQuery(s:String):String;就是通过一个模糊查询得到结果值的函数。DBGrid中没有这个事件,可以这样解决,在 OnKeyDown中写入下代码
    if key = #13 then
    begin
      if DBGrid1.SelectedField.Value<>'' then
        DBGrid1.Columns.Items[DBGrid1.SelectedIndex].Field.Value :=    GetValueByQuery(DBGrid1.Columns.Items[DBGrid1.SelectedIndex].Field.Value);end
      

  3.   

    可以设计成点BUTTON则showmodal一个查询窗口呀!在从中