//沒有測試,你自己測試一下吧
var
i,j,m,n:integer;
sTmp :string;
begin
for i:=0 to stringgrid1.Rowcount do
for j := 0 to stringgrid1.colcount do
begin
sTmp := Trim(stringgrid1.cell[i,j]);
if sTmp = '' then
begin
ShowMessage(IntToStr(i+1)+' Row and '+ IntToStr(j+1) + ' Col is Null!');
Exit;
end; for m := i to stringgrid1.Rowcount do
for n := 0 to stringgrid1.colcount do
begin
if sTmp = Trim(stringgrid1.cell[m,n]) then
begin
ShowMessage(IntToStr(i+1)+' Row and '+ IntToStr(j+1) + ' Col ='+
IntToStr(m+1)+' Row and '+ IntToStr(n+1) + ' Col!');
Exit;
end;
end;
end;
end;
var
i,j,m,n:integer;
sTmp :string;
begin
for i:=0 to stringgrid1.Rowcount do
for j := 0 to stringgrid1.colcount do
begin
sTmp := Trim(stringgrid1.cell[i,j]);
if sTmp = '' then
begin
ShowMessage(IntToStr(i+1)+' Row and '+ IntToStr(j+1) + ' Col is Null!');
Exit;
end; for m := i to stringgrid1.Rowcount do
for n := 0 to stringgrid1.colcount do
begin
if sTmp = Trim(stringgrid1.cell[m,n]) then
begin
ShowMessage(IntToStr(i+1)+' Row and '+ IntToStr(j+1) + ' Col ='+
IntToStr(m+1)+' Row and '+ IntToStr(n+1) + ' Col!');
Exit;
end;
end;
end;
end;
var i_count,i_row,i_col :integer;
begin
if trim(stringgrid1.Cells[x,y])='' then
begin
showmessage('为空!');
exit;
end;
i_count:=0;
for i_row:=0 to stringgrid1.RowCount-1 do
begin
for i_col:=0 to stringgrid1.ColCount-1 do
begin
if stringgrid1.cells[x,y]=
stringgrid1.cells[i_col,i_row then
i_count:=i_count + 1;
if i_count>1 then
begin
showmessage('跟第i_row行、第i_col列一致!');
exit;
end;
end;
end;end;
var i_row,i_col:integer;
begin
if trim(stringgrid1.Cells[x,y])='' then
begin
showmessage('为空!');
exit;
end;
for i_row:=0 to stringgrid1.RowCount-1 do
begin
for i_col:=0 to stringgrid1.ColCount-1 do
begin
if stringgrid1.cells[x,y]=
stringgrid1.cells[i_col,i_row] then
begin
if (i_row<>y) or (i_col<>x) then
begin
showmessage('跟第' + i_row +'行、第' + i_col + '列一致!');
exit;
end;
end;
end;
end;end;
请见晾