首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

小女子先行谢过了~有关datagrid控件,该怎么处理

2012-03-23 
小女子先行谢过了~有关datagrid控件我想在datagrid控件中,锁定一行,注意,是一行,行!该怎么做?先谢谢大伙了

小女子先行谢过了~有关datagrid控件



          我想在datagrid控件中,锁定一行,注意,是一行,行!该怎么做?    
          先谢谢大伙了~~

[解决办法]
用DBGRid吧
[解决办法]
隻能進行列鎖定
给你一个在STRINGGRID中设置只读列的程序代码
DBGRID应该也差不多把
procedure TWORK_Plan.StringGrid2SelectCell(Sender: TObject; ACol,
ARow: Integer; var CanSelect: Boolean);
var
R: TRect;
begin
empolyee.VISIBLE:=FALSE;
NUM.VISIBLE:=FALSE;

With Sender As TStringgrid Do

If trim(Cells[4,arow])= ' ' then
Begin
Cells[3,arow]:= 'Insert ';
Cells[4,arow]:= '0011 ';
End;

With Sender As TStringgrid Do

If (ACol = 1) or (ACol = 2) and (ARow > = FixedRows) Then //在第二列显示一个ComboBox
Begin
//取消选中模式
perform( WM_CANCELMODE, 0, 0 );

//确定ComboBox的位置
R := CellRect( Acol, Arow );

if acol=1 then
With empolyee do
begin
setbounds( R.left, R.top, r.right-r.left, height );
itemindex := Items.IndexOf( Cells[ acol, arow ] );
Show;
BringTofront;

//使得ComboBox称为输入的焦点
SetFocus;

//DroppedDown := true;
end;

if acol=2 then
With NUM do
begin
setbounds( R.left, R.top, r.right-r.left, height );
text:=cells[acol,arow];
Show;
BringTofront;
SETFOCUS;;
//使得ComboBox称为输入的焦点
//DroppedDown := true;
end;
End
Else

if access[1]= '2 ' then
bEGIN
if acol=5 then
if Stringgrid2.cells[1,arow]=logon_user then
Stringgrid2.options:=[goFixedVertLine,goFixedHorzLine,goVertLine,goHorzLine,goRangeSelect,goEditing,goAlwaysShowEditor]
else
stringgrid2.Options:=[goFixedVertLine,goFixedHorzLine,goVertLine,goHorzLine,goRangeSelect];

if acol=6 then
//if Stringgrid2.cells[1,arow]=logon_user then
Stringgrid2.options:=[goFixedVertLine,goFixedHorzLine,goVertLine,goHorzLine,goRangeSelect,goEditing,goAlwaysShowEditor];
// else
// Stringgrid2.options:=[goFixedVertLine,goFixedHorzLine,goVertLine,goHorzLine,goRangeSelect];

END;
//设置哪个COL为只读选项

if access[1]= '1 ' then
begin
if (acol=5) then
if Stringgrid2.cells[1,arow]=logon_user then


Stringgrid2.options:=[goFixedVertLine,goFixedHorzLine,goVertLine,goHorzLine,goRangeSelect,goEditing,goAlwaysShowEditor]
else
stringgrid2.Options:=[goFixedVertLine,goFixedHorzLine,goVertLine,goHorzLine,goRangeSelect];

if (acol=6) then
stringgrid2.Options:=[goFixedVertLine,goFixedHorzLine,goVertLine,goHorzLine,goRangeSelect];

End;
//设置哪个COL为只读选项

if ACCESS[1]= '3 ' then
if acol=5 then
if Stringgrid2.cells[1,arow]=logon_user then
Stringgrid2.options:=[goFixedVertLine,goFixedHorzLine,goVertLine,goHorzLine,goRangeSelect,goEditing,goAlwaysShowEditor]
else
Stringgrid2.options:=[goFixedVertLine,goFixedHorzLine,goVertLine,goHorzLine,goRangeSelect];
if acol=6 then
Stringgrid2.options:=[goFixedVertLine,goFixedHorzLine,goVertLine,goHorzLine,goRangeSelect];
end;

热点排行