放一个COMBOX 如果单击GRID非COMBOX列时隐藏 BEGIN Grid.Cells[Grid.Col,0]<>'列名') END;GridDrawCell事件中代码如下 if (gdFocused in State) then begin //对应字段一致则执行 if (Grid.Cells[ACol,0]='列名') then begin //移动下拉框到指定位置 combox.Left := Rect.Left + Grid.Left; comboxx.Top := Rect.Top + Grid.top; combox.Width :=Rect.Right-Rect.Left; combox.Height:=Rect.Bottom-Rect.Top; // 使下拉框可见并获得焦点 combox.Visible := True; combox.SetFocus; end; end; 在COMBOX CHANGE事件中写 GRID.CELLS(GRID.COL,GRID.ROW):=COMBOX.TEXT
请问楼上的,我的StringGrid名为SGd,但为什么我的if (gdFocused in State) then 一句总是判断为False,也就是怎么我的ShowMessage('OK')一句怎么也不能执行? if (gdFocused in State) then begin ShowMessage('OK'); if (SGd.Cells[ACol,0]='列二') then begin cmbHide.Left := Rect.Left + SGd.Left; cmbHide.Top := Rect.Top + SGd.top; cmbHide.Width :=Rect.Right-Rect.Left; cmbHide.Height:=Rect.Bottom-Rect.Top; CmbHide.Visible := True; cmbHide.SetFocus; end; end;
楼上的给出思路应该是正确的。 http://bbs.chinaworkroom.com
我也觉得这样做应当是可行的,但就不知道为什么我的StringGrid名为SGd,但为什么我的if (gdFocused in State) then 一句总是判断为False,也就是怎么我的ShowMessage('OK')一句怎么也不能执行? 我已经执行双击了?!
如果单击GRID非COMBOX列时隐藏
BEGIN
Grid.Cells[Grid.Col,0]<>'列名')
END;GridDrawCell事件中代码如下
if (gdFocused in State) then
begin
//对应字段一致则执行
if (Grid.Cells[ACol,0]='列名') then
begin
//移动下拉框到指定位置
combox.Left := Rect.Left + Grid.Left;
comboxx.Top := Rect.Top + Grid.top;
combox.Width :=Rect.Right-Rect.Left;
combox.Height:=Rect.Bottom-Rect.Top;
// 使下拉框可见并获得焦点
combox.Visible := True;
combox.SetFocus;
end;
end;
在COMBOX CHANGE事件中写
GRID.CELLS(GRID.COL,GRID.ROW):=COMBOX.TEXT
begin
ShowMessage('OK');
if (SGd.Cells[ACol,0]='列二') then
begin
cmbHide.Left := Rect.Left + SGd.Left;
cmbHide.Top := Rect.Top + SGd.top;
cmbHide.Width :=Rect.Right-Rect.Left;
cmbHide.Height:=Rect.Bottom-Rect.Top;
CmbHide.Visible := True;
cmbHide.SetFocus;
end;
end;
http://bbs.chinaworkroom.com
我已经执行双击了?!