方法 (1)
for i:=0 to DBGrid1.Columns.Count-1 do
begin
DbGird.Columns[i].ReadOnly := True;//全部只读
end;
DbGird.Columns[1].ReadOnly := False;第二列可编辑~~
方法 (2)
双击dbgrid,加入所有字段,将除可编辑的列外的其它列的readonly属性设为true
或双击对应的dateset,加入所有字段,将除可编辑的字段外的其它字段的readonly属性设为true
方法 (3)
将其它保持只读得TColumn得ReadOnly属性设为True。需要编辑得,ReadOnly属性设为False。
本文介绍了三种在Delphi中使用DBGrid时设置列只读的方法:通过代码遍历所有列并设置ReadOnly属性、手动设置除可编辑列外的其他列的ReadOnly属性以及直接在TColumn中设置ReadOnly属性。
1944

被折叠的 条评论
为什么被折叠?



