
var
LStrList:TStrings;
begin
LStrList := TStringListCreate;
LStrListDelimiter := '$';
LStrListDelimitedText :='断裂拉伸强度$撕裂强度$扯断伸长率$粘接剥离强度$不透水性$低温弯折';
{LStrList里方的就是
断裂拉伸强度
撕裂强度
扯断伸长率
粘接剥离强
不透水性
低温弯折}
end;
使用DataSourceDataSetRecNo可以得到dbgrid选中的是第几行,示例代码如下:
procedure TForm1btn1Click(Sender: TObject);begin
ShowMessage(IntToStr(dbgrd1DataSourceDataSetRecNo));
end;
效果如下:
比较麻烦,目前想到一个笨办法。
{
显示DBGrid中鼠标指向的记录号
by 宋银海
}
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids, DBGrids, DB, DBTables;
type
TForm1 = class(TForm)
Table1: TTable;
DataSource1: TDataSource;
DBGrid1: TDBGrid;
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure DBGrid1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
private
{ Private declarations }
FDBRow:Integer;
FDBCurrentRec:Integer;
public
{ Public declarations }
published
property DBRow: Integer read FDBRow write FDBRow;
property DBCurrentRec: Integer read FDBCurrentRec write FDBCurrentRec;
end;
var
Form1: TForm1;
implementation
{$R dfm}
procedure TForm1Button1Click(Sender: TObject);
begin
if not Table1Active then
Table1Open;
end;
procedure TForm1DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
DBRow:=(RectBottom-DBGrid1Top+1) div (RectBottom-RectTop+1);
DBCurrentRec:=DBGrid1DataSourceDataSetRecNo;
end;
procedure TForm1DBGrid1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
var
pt:TGridCoord;
begin
pt:=(Sender as TDBGrid)MouseCoord(x,y); //获取DBGrid中的坐标
Caption:='鼠标指向记录号是 '+IntTostr(DBCurrentRec+ptY-DBRow);
end;
end
ADO连接文本文件
adoquery连接字符串
Provider=MicrosoftJetOLEDB40;Data Source=文本文件的目录;Extended Properties=text;Persist Security Info=False
然后在ADOQuery中写SQL为
select from 你的文本文件名
以上就是关于delphi DBGrid 获取字段里的值进行循环截取并取值 怎么实现的啊!全部的内容,包括:delphi DBGrid 获取字段里的值进行循环截取并取值 怎么实现的啊!、DELPHI dbgrid 选中的是第几行 怎么判断、delphi中 DBGrid显示数据库内容,使用MouseCoord(X,Y)获取鼠标指向的是第几条记录等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)