用StringGrid里面的网格竟然没有对齐方式,DBGrid 就可以。瞒以为下了个大名鼎鼎的AdvStringGrid,可是还是不行,简直是没有公理,天啊!。
给我个解决办法先!
解决方案 »
- delphi excel 设置文本格式
- SendMessage 不能取TDxDraw类型的输入框的值?
- 求教具体操作:字符串过长,想切成几段,然后赋值给commandtext。
- 我使用ASA数据库(PB开发常用),但是在DELPHI中使用SQL语句,有下面的问题,请大家指教。
- 用idHTTP.get(URL)请求返回'010'#$A,这个#$A是什么意思啊
- 如何模糊查询??(比较麻烦)
- 请教DBGrid 录入中,怎样使光标锁定录入框有TEdit 的风格?
- 有关程序的启动问题,
- Rmb求助软件界面配色贴图方案!!!!!!!!
- 请教bcb中,midas客户端调用 服务器端的方法,
- 那位大哥有d7 的报表教程(给弟弟一份把)
- 在DELPHI中如何识别条码扫描器的信息
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin
StringGrid1.Canvas.TextRect(rect,0,0,StringGrid1.Cells[Acol,Arow]);
StringGrid1.Canvas.Textout(rect.Left,rect.Top,StringGrid1.Cells[Acol,Arow]);//左对齐,其他雷同
end;Microsoft OLE DB Provider for SQL Server 错误 '80040e31' 超时已过期 /Expert/reply.asp,行105
比如想要使字符串网格的第一行字符居中对齐,其他行右对齐,可以通过StringGrid.OnDrawCell事件处理来完成。procedure WriteText(ACanvas: TCanvas; const ARect: TRect; DX, DY: Integer;
const Text: string; Format: Word);
var
S: array[0..255] of Char;
B, R: TRect;begin
with ACanvas, ARect do
begin
case Format of
DT_LEFT : ExtTextOut(Handle, Left + DX, Top + DY, ETO_OPAQUE or
ETO_CLIPPED, @ARect, StrPCopy(S, Text),
length(Text), nil); DT_RIGHT : ExtTextOut(Handle, Right - TextWidth(Text) - 3, Top + DY,
ETO_OPAQUE or ETO_CLIPPED, @ARect, StrPCopy(S, Text), Length(Text), nil); DT_CENTER : ExtTextOut(Handle, Left + (Right - Left - TextWidth(Text)) div 2, Top + DY, ETO_OPAQUE or ETO_CLIPPED, @ARect,
StrPCopy(S, Text), Length(Text), nil);
end;
end;
end;
procedure TBEFStringGrid.DrawCell(Col, Row: Longint; Rect: TRect; State: TGridDrawState);
var procedure Display(const S: string; Alignment: TAlignment);
const
Formats: array[TAlignment] of Word = (DT_LEFT, DT_RIGHT, DT_CENTER);
begin
WriteText(Canvas, Rect, 2, 2, S, Formats[Alignment]);
end;begin
case Row of
0 : { 居中对齐第一行 }
if (Col < ColCount) then
Display(Cells[Col,Row], taCenter)
else
{ 右对齐其他行 }
Display(Cells[Col,Row], taRight);
end;end;
在字符串网格中画图只需要处理StringGrid.OnDrawCell事件就可以了 with StringGrid1.Canvas do
begin
{...}
Draw(Rect.Left, Rect.Top, Image1.Picture.Graphic);
{...}
end;