cxgrid 让搜索框随表格位置变化

让搜索框随表格位置变化
在做一个数据录入的时候,经常用到,有些数据需要从代码表中进行录入,但一般的表格控件又不支持根据助记码进行搜索,保存编码,所以一般会设计成,选中某列以后,根据需要自动弹出代码列表供用户选择,下面的例子就是序代码表弹出的位置,可以处由变换的例子,当然可以根据自己需要修改什么时候可见,什么时候不可见:
procedure TForm1.vwFocusedItemChanged(Sender: TcxCustomGridTableView;
APrevFocusedItem, AFocusedItem: TcxCustomGridTableItem);
begin
//编辑格left
MyLeft:=AFocusedItem.FocusedCellViewInfo.Bounds.left;
myPos:=point(MyLeft,MyTop);
//转换位置为相对于form的x,y
myPos:=cxGrid1.ClientToParent(myPos,Self);
//计算srchGrid是否超出form的下边界
if (MyPos.Y+1+SrchGrid.Height)<=Self.Height then
SrchGrid.Top:=myPos.y+1
else
SrchGrid.Top:=MyPos.Y-1-cellHeight-SrchGrid.Height;
SrchGrid.Left:=myPos.X;
end;

procedure TForm1.vwFocusedRecordChanged(Sender: TcxCustomGridTableView;
APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord;
ANewItemRecordFocusingChanged: Boolean);
begin
//行高
CellHeight:=AFocusedRecord.ViewInfo.Bounds.Bottom-
AFocusedRecord.ViewInfo.Bounds.Top;
//编辑格bottom
MyTop:=AFocusedRecord.ViewInfo.Bounds.Bottom;
myPos:=point(MyLeft,MyTop);
//转换位置为相对于form的x,y
myPos:=cxGrid1.ClientToParent(myPos,Self);
//计算srchGrid是否超出form的下边界
if (MyPos.Y+1+SrchGrid.Height)<=Self.ClientHeight then
SrchGrid.Top:=myPos.y+1
else
SrchGrid.Top:=MyPos.Y-1-cellHeight-SrchGrid.Height;
SrchGrid.Left:=myPos.X;
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值