在StringGrid中如何实现一个单元格中输出两行信息,还要其自动居中,
我要做一个试题的信息,显示的时候每单元格显示一个题号,当用户点击某个单元格时再将试题答案显示在当前单元格的下一行,如下:
┏━━┳━━┳━━┓
┃ 1 ┃ 2 ┃ 3 ┃
┃ A ┃ B ┃ C ┃
┗━━┻━━┻━━┛
请各位帮忙解决一下等着用啊,谢谢了!!!
我要做一个试题的信息,显示的时候每单元格显示一个题号,当用户点击某个单元格时再将试题答案显示在当前单元格的下一行,如下:
┏━━┳━━┳━━┓
┃ 1 ┃ 2 ┃ 3 ┃
┃ A ┃ B ┃ C ┃
┗━━┻━━┻━━┛
请各位帮忙解决一下等着用啊,谢谢了!!!
2)自己写OnCellDraw或类似的事件
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin
if (acol=1) and (arow=1) then
begin
textout(stringgrid1.Canvas.handle, rect.left,rect.top,pchar('第一行文字'),12);
textout(stringgrid1.Canvas.handle, rect.left,rect.top+12,pchar('第二行文字'),12);
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
StringGrid1.Options:=StringGrid1.Options+[goEditing];
StringGrid1.Cells[1,1]:='第二行文字';
end;