用StringGrid如何合并标题头,像这样(性别占两格):
_______________
|____性别_____|
|__男__|__女__|
|______|______|
_______________
|____性别_____|
|__男__|__女__|
|______|______|
解决方案 »
- List index out of bounds (1)
- 有看过或改过胜天财务进销存2003版(单机版)的朋友请帮下!
- 关于数据显示问题。谢谢各位
- 怎样编写一个Delphi获取modem来电号码的程序?
- DCOM连接系统的一个怪问题,数据能看到但无法提交修改?
- 怎样使dbgrid随form大小变化而变化,up有分!!!欢迎捧场!!!(在先等待)
- 谁做过类似“网易短信王”的软件,可以帮小弟一下吗?急.......
- 关于屏幕刷新问题!急!!
- 谁有例子:在状态条上放置一个进度条?
- 怎样获得所有窗体的句柄?
- 高分求救!编译问题??????
- 模式窗口的返回值(非ModalResult),就是文件对话框返回的Filename,Filenames
找一个第三方控件试试了
其实在common目录下是有的
听说要吧common目录添加到编译目录中,有谁知道怎么加吗
谢谢
事太多、心太乱
用StringGrid可以实现合并标题头?怎么做可以说说吗,谢谢
请讲详细一点,多谢了
Rect: TRect; State: TGridDrawState);
begin
if (ACol=x) and (ARow=y) then
begin
StringGrid1.Canvas..... // 在这里把这个 Rect 分为两部分
end;
end;
你说的DM控件全名叫什么,哪有下
其实在common目录下是有的
听说要吧common目录添加到编译目录中,有谁知道怎么加吗
谢谢
--------------
我实验过,只要把common目录下的所有文件拷贝到delphi7那个文件夹下就可以了。
Left = 192
Top = 107
Width = 394
Height = 312
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 13
object StringGrid1: TStringGrid
Left = 0
Top = 0
Width = 386
Height = 285
Align = alClient
ColCount = 2
FixedCols = 0
FixedRows = 2
Options = [goVertLine, goHorzLine, goRangeSelect, goColSizing]
TabOrder = 0
OnDrawCell = StringGrid1DrawCell
ColWidths = (
111
109)
end
end
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Grids;type
TForm1 = class(TForm)
StringGrid1: TStringGrid;
procedure FormCreate(Sender: TObject);
procedure StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
ARect: TRect; AState: TGridDrawState);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.DFM}procedure TForm1.FormCreate(Sender: TObject);
begin
with StringGrid1 do
begin
Cells[0, 0] := '性';
Cells[1, 0] := '别';
Cells[0, 1] := '男';
Cells[1, 1] := '女';
end;
end;procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
ARect: TRect; AState: TGridDrawState);
var
strValue: String;
intMargin, intHeight, intWidth: Integer;
begin
with TStringGrid(Sender) do
begin
// 画背景
if gdFixed in AState then
Canvas.Brush.Color := FixedColor
else
Canvas.Brush.Color := Color;
Canvas.FillRect(ARect); // 计算显示在矩形框中的左上角位置
strValue := Cells[ACol, ARow];
Canvas.Font := Font;
intWidth := Canvas.TextWidth(strValue);
if (ARow = 0) and (ACol = 0) then
intMargin := ARect.Right - ARect.Left - intWidth - 6
else if (ARow = 0) and (ACol = 1) then
intMargin := 6
else
begin
intMargin := (ARect.Right - ARect.Left - intWidth) div 2;
if intMargin < 0 then
intMargin := 0;
end; // 在矩形框中写值
intHeight := (ARect.Bottom - ARect.Top - Canvas.TextHeight(strValue)) div 2;
Canvas.TextRect(ARect, ARect.Left + intMargin, ARect.Top + intHeight, strValue); // 画线
if gdFixed in AState then
begin
Canvas.Pen.Mode := pmCopy;
Canvas.Pen.Style := psSolid;
Canvas.Pen.Width := 1; // 上边和左边线
Canvas.Pen.Color := clWhite;
Canvas.PenPos := Point(ARect.Right, ARect.Top);
Canvas.LineTo(ARect.Left, ARect.Top);
if (ARow <> 0) or (ACol <> 1) then
Canvas.LineTo(ARect.Left, ARect.Bottom); // 下边和右边线
Canvas.Pen.Color := clBtnShadow;
Canvas.PenPos := Point(ARect.Left, ARect.Bottom);
Canvas.LineTo(ARect.Right, ARect.Bottom);
if (ARow <> 0) or (ACol <> 0) then
Canvas.LineTo(ARect.Right, ARect.Top);
end;
end;
end;end.
http://www.2ccc.com