三層問題,當我在dbgrid中用combobox來做為查找項時出現閃爍狀態,不知是何原因(100分)

J

johnlhr

Unregistered / Unconfirmed
GUEST, unregistred user!
當我用以下語句進行作業時,在c/s結釵下沒問題,當在三層下時出現明顯閃爍,請問各位有何辦漢取消
此種現象
procedure TMAINFACEF.DBGrid1DrawDataCell(Sender: TObject;
const Rect: TRect; Field: TField; State: TGridDrawState);
begin
if ((gdfocused in state) or (gdselected in state)) and (field.fieldname='CARD_CATEGORY') then
begin
DBComboBox1.Left:=rect.left+DBGrid1.Left+1;
DBComboBox1.top:=rect.top+DBGrid1.top+1;
DBComboBox1.width:=rect.right-RECT.left;
DBComboBox1.height:=rect.bottom-RECT.top;
DBComboBox1.Visible:=true;
end;
end;

 
procedure TMAINFACEF.DBGrid1DrawDataCell(Sender: TObject;
const Rect: TRect; Field: TField; State: TGridDrawState);
begin
if ((gdfocused in state) or (gdselected in state)) and (field.fieldname='CARD_CATEGORY') then
begin
DBComboBox1.Visible:=false;///加上这句
DBComboBox1.Left:=rect.left+DBGrid1.Left+1;
DBComboBox1.top:=rect.top+DBGrid1.top+1;
DBComboBox1.width:=rect.right-RECT.left;
DBComboBox1.height:=rect.bottom-RECT.top;
DBComboBox1.Visible:=true;
end;
end;
 
這樣不行啊,老大,
 
这好像是窗体的显示问题吧,查询时你不要把窗体最大化就可以了.
我也不知道什么原因。
 
先定义全局变量:OldRect: TRect;

procedure TForm1.DBGrid1DrawDataCell(Sender: TObject; const Rect: TRect;
Field: TField; State: TGridDrawState);
begin
if (OldRect.Left =Rect.Left)
and (OldRect.Top=Rect.Top) then exit;
if ((gdfocused in state) or (gdselected in state))
and(lowerCase(field.fieldname)='stkcode')
then
begin
OldRect.Left := Rect.Left;
OldRect.Top := Rect.Top;
DBComboBox1.Left:=rect.left+DBGrid1.Left+1;
DBComboBox1.top:=rect.top+DBGrid1.top+1;
DBComboBox1.width:=rect.right-RECT.left;
DBComboBox1.height:=rect.bottom-RECT.top;
DBComboBox1.Visible:=true;
end;
end;
 
多人接受答案了。
 
顶部