如何选中DBGrid中的一行记录???? 在Delphi中如何选中DBGrid中的一行记录????我想选中dbgrid中的一条记录,并取出每一列的值,请问用何种方法,请各位大侠指教,谢谢??? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 用fieldByName('列名').asstring就可以搞定! 先用DataSet.Locate定位记录,再用楼上的方法取值就OK fieldByName('FieldName').Value;我也来闹热闹热。 那在Delphi中如何选中DBGrid中的一行记录,并把该行变为蓝色呢???? 我的意思是说:我在DBGrid中选中的只是一列,我想选中的是一行,有什么属性或函数吗??? 首先把记录定位到你要的那行,直接用鼠标点,或者在代码里用locate定位。在利用adoquery.fieldByName('列名1').asstring adoquery.fieldByName('列名2').asstring ......取到每个字段列的值! To dragonth(幽灵剑客)那在Delphi中如何选中DBGrid中的一行记录,并把该行变为蓝色呢????在DBGrid1的DrawColumnCell事件中写:比如对编号为0001的记录改变颜色procedure Tform1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState);var str: string;begin str := Adodataset2.fieldbyname('编号).Asstring; if (trim(str) = '0001') then begin DBGrid1.Canvas.Font.Color := clyellow; DBGrid1.Canvas.Brush.Color := clblue; end; DBGrid1.DefaultDrawColumnCell(Rect, DataCol, Column, State);end; 在DBgrid中有一个属性可以Option->dgRowSelect 把它改为true即可。 在DBgrid中的属性Option选择dgRowSelect 把它改为true即可。然后在DBGrid1DrawColumnCell事件中写取值的代码就可以了,如trade_id:=Query1.FieldByName('trade_id').asstring ;mobile:=Query1.FieldByName('mobile').asstring ;order_time:=Query1.FieldByName('order_time').asstring ;content:=Query1.FieldByName('content').asstring ;payment_status:=Query1.FieldByName('payment_status').asinteger;delivery_status:=Query1.FieldByName('delivery_status').asinteger;把变量声明为单元中的全局变量就可以了 求sql语句 那为能讲讲三层模型开发 why提示我不能操作关闭的数据集? USB1.1实时通讯和控制U盘文件 关于QReport报表的QRShape适应报表字段大小的问题和QRDBRichText不显示数据的问题 我用AnimateWindow做动画窗体,为什么看不到窗体上的图片了? 谁来救救我的Delphi程序资料 如何取得field 中的number值?? 有没有青岛的朋友,联系 救命呀!!那位兄弟用过Tcriticalsection临界资源安全对象? 一个很简单但快让我疯了的问题 怎样定义一个数组类型的属性?
我也来闹热闹热。
直接用鼠标点,或者在代码里用locate定位。
在利用adoquery.fieldByName('列名1').asstring
adoquery.fieldByName('列名2').asstring
......
取到每个字段列的值!
比如对编号为0001的记录改变颜色
procedure Tform1.DBGrid1DrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn;
State: TGridDrawState);
var str: string;
begin
str := Adodataset2.fieldbyname('编号).Asstring;
if (trim(str) = '0001') then
begin
DBGrid1.Canvas.Font.Color := clyellow;
DBGrid1.Canvas.Brush.Color := clblue;
end;
DBGrid1.DefaultDrawColumnCell(Rect, DataCol, Column, State);
end;
Option->dgRowSelect 把它改为true即可。
然后在DBGrid1DrawColumnCell事件中写取值的代码就可以了,如trade_id:=Query1.FieldByName('trade_id').asstring ;
mobile:=Query1.FieldByName('mobile').asstring ;
order_time:=Query1.FieldByName('order_time').asstring ;
content:=Query1.FieldByName('content').asstring ;
payment_status:=Query1.FieldByName('payment_status').asinteger;
delivery_status:=Query1.FieldByName('delivery_status').asinteger;
把变量声明为单元中的全局变量就可以了