在线等!不连接数据库,如何手动往DBGrid中插入数据啊? 我是从ini文件里读数据,放到DBGrid中现实,如何做?有什么函数啊,给个例子吧,非常感谢! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 思路:delphi中一般用datasource来做为dbgrid的数据源,简单些的方法就是你不用AdoDataset连数据库,而连接本机硬盘上的物理数据源文件,ado是支持的,你把你的INI数据生成带有分隔符或固字段长的纯文件数据文件,然后用ado的连接对象来连接。 用StringGrid就可以了何必用DBGrid??? 有數據源,用DBGrid,往數據源裡插數據,沒有數據源,用StringGrid,直接往單元格裡插數據。 那能给一个把一个字符串数组插入到StringGrid中的一行的例子吗?比如:name dfsd sdfsf dfsdfname1 dfsdf dfsdf sdfsdf 呵呵,ClientDataSet就是专门用来处理离线的数据库的。数据更改后,再连线更新到远程数据库。ClientDataSet是从DataSet继承来的,当然支持DBGrid的标准操作啦。ADO.net就是复制的这个模式做的。 那能给一个把一个字符串数组插入到StringGrid中的一行的例子吗?比如:name dfsd sdfsf dfsdfname1 dfsdf dfsdf sdfsdf--------循环写撒 with stringgrid1 do begin for i:=1 to FieldCount do for j;=1 to RowCount do begin stringgrid1.Cells[i,j] := ... //读取内容 end; end; StringGrid1.ColCount := 4;StringGrid1.RowCount := 3; // 假设有一标头 StringGrid1.FixedRows = 1// 标头StringGrid1.Cells[0, 0] := '标头1';StringGrid1.Cells[1, 0] := '标头2';StringGrid1.Cells[2, 0] := '标头3';StringGrid1.Cells[3, 0] := '标头4';// 第一行StringGrid1.Cells[0, 1] := 'name';StringGrid1.Cells[1, 1] := 'dfsd';StringGrid1.Cells[2, 2] := 'sdfsf';StringGrid1.Cells[3, 3] := 'dsfsf';// 第二行StringGrid1.Cells[0, 2] := 'name1';StringGrid1.Cells[1, 2] := 'dfsd';StringGrid1.Cells[2, 2] := 'sdfsf';StringGrid1.Cells[3, 2] := 'dsfsf'; j:=1; while not EOF do begin StringGrid1.Cells[0,j] := fieldbyname( 'name').AsString; StringGrid1.Cells[1,j] := fieldbyname('dfsd').AsString; StringGrid1.Cells[2,j] := fieldbyname('sdfsf').AsString; StringGrid1.Cells[3,j] := fieldbyname('dsfsf').AsString; StringGrid1.RowCount:=j+1; inc(j); next; end; 建议 将ini改为xml 用ClientDataset控件很方便 有没有delphi网络传输文件的例子 前辈和高手请进,关于CMD命令的输入输出,在线等 初来,请指教,a=5,和a:=5有什么区别? 怎么样才能得到端口 在屏幕绘图 如何调用记事本?? 向数据库中添加JPEG图片的问题。 请问如何将日期格式的字段分别取出年,月,日 关于VC++、JAVA、C#、DELPHI它们各自的优缺点剖析 请问各位前辈: 在执行中出现"incorrect syntax near 'JCSZ'"的错误提示,如何解决? 一段有趣的代码(被卡巴斯基当成木马) 110---救我呀!
比如:
name dfsd sdfsf dfsdf
name1 dfsdf dfsdf sdfsdf
ClientDataSet是从DataSet继承来的,当然支持DBGrid的标准操作啦。
ADO.net就是复制的这个模式做的。
比如:
name dfsd sdfsf dfsdf
name1 dfsdf dfsdf sdfsdf--------循环写撒
begin
for i:=1 to FieldCount do
for j;=1 to RowCount do
begin
stringgrid1.Cells[i,j] := ... //读取内容
end;
end;
StringGrid1.RowCount := 3; // 假设有一标头 StringGrid1.FixedRows = 1
// 标头
StringGrid1.Cells[0, 0] := '标头1';
StringGrid1.Cells[1, 0] := '标头2';
StringGrid1.Cells[2, 0] := '标头3';
StringGrid1.Cells[3, 0] := '标头4';
// 第一行
StringGrid1.Cells[0, 1] := 'name';
StringGrid1.Cells[1, 1] := 'dfsd';
StringGrid1.Cells[2, 2] := 'sdfsf';
StringGrid1.Cells[3, 3] := 'dsfsf';
// 第二行
StringGrid1.Cells[0, 2] := 'name1';
StringGrid1.Cells[1, 2] := 'dfsd';
StringGrid1.Cells[2, 2] := 'sdfsf';
StringGrid1.Cells[3, 2] := 'dsfsf';
j:=1; while not EOF do
begin
StringGrid1.Cells[0,j] := fieldbyname( 'name').AsString;
StringGrid1.Cells[1,j] := fieldbyname('dfsd').AsString;
StringGrid1.Cells[2,j] := fieldbyname('sdfsf').AsString;
StringGrid1.Cells[3,j] := fieldbyname('dsfsf').AsString;
StringGrid1.RowCount:=j+1;
inc(j);
next;
end;
将ini改为xml
用ClientDataset控件
很方便