var Rect: Trect; begin Rect:= bg.CellRect(4,3); bg.Canvas.Brush.Color:= clwhite; bg.Canvas.FillRect(rect); bg.Canvas.Draw( rect.Left +trunc(( rect.Right- rect.Left -tx2.Width )/2 ) //单元格 水平居中 , rect.Top +trunc( (20- tx2.Height) /2 ) ,tx2.Picture.Graphic ); end;
object Form5: TForm5 Left = 0 Top = 0 Caption = 'Form5' ClientHeight = 598 ClientWidth = 854 Color = clBtnFace Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -11 Font.Name = 'Tahoma' Font.Style = [] OldCreateOrder = False OnCreate = FormCreate PixelsPerInch = 96 TextHeight = 13 object tx2: TImage Left = 688 Top = 248 Width = 16 Height = 16 AutoSize = True Picture.Data = { 0954506E67496D61676589504E470D0A1A0A0000000D49484452000000100000 001008060000001FF3FF610000001974455874536F6674776172650041646F62 6520496D616765526561647971C9653C0000000D744558745469746C65005065 72736F6E3B5F31C58F000002FA4944415478DA7D927B48935118C69F993953C3 2E922C456DD9B0D42E964144994974A55116169982ED8FB00B11664550414449 4517A230E91F6B418AB78595C9124D4B73BA9AB3E9746B316F9B3AB7E9F6EDFB BE6D5F476A19117BE1E17DCF39EFF33B07CECBE3380E7FC7D9783E5C5E4ECCBA 7196F57229AC871B72BA71A57ACCF392FBB79904EFDFBD134BF8097323162853 77A50787858762DC64466D99DCE308F05CA7DC9E3B753F18BB5FC0F1B8A00729 DBD34E45462F8241D3871EB5010BA3059C46DBCB232F2A92E9E90B7E019298A0 CA8DE28C7DAAB61EACCAD889D4F495307FEF43C9BD2763368A6EAB35307BFC02 B2A3665FE5F3F997EFB6F6F2420286E01C51A05BA142557185FDCB80A5FA9DD1 9DEB17200A9D15B32751D077ED6D475080B50113833AE835FDA82CAEB1D7F45B B7EA6CDE0EBF001E8F37BF282BB55E9C7F696D44E810CC462DD4AD5D9055B575 3ED74EED25FD83FF059CB9598AFB17730349B9F8E4FEF4A28C94A5872263A360 312808A0070D7AE6759DC65848CEFB0FE415D0E54F6FCD00C8ADD3353F2A4E24 DA223E5A9C9490B0013A39E60CB68372B8F08D152036ED20148A76D52779CD69 DBC4A882F43BA7E7C207088C4F5C97BC3B4B529F2DCE58B86A451C1E3E9562C3 E27118546A54E8E6E1EA8553F8611C424969D964E39BF27D13A3C31F8897F101 C23325E71FE61CCECCDEB1690D2CD64974A8BAD1D4F21963162B925688205A26 84D345A3FB9B161565E5B5EACFF263C46BF201A2F30A6F375FCC3F12CB710118 B5D81116C2C3806912143105077B3138E20445D398B29B50512E332B9BAA3713 6FAF0F109F7FE5B1FA66410EBFEEA31E363B85E4656168EA34C349B991289C85 D6AE29D0B407B18229489F55BA958D95EB89573903B8FC487DE35C0EFFD57B2D AC0E1AC9F173D0DC398E49278B2421D0DEED82C3E5855060C30B6915AB6E91AD 25DE2E1F20625BA6E48670F96A899B65E16618302C0D8676915B69B8288A6452 BB7EADCDC67EE9B0FE6B01F18EFCF905F22DF389161105FB66E4B7F0579E0E86 6884689C78D99FB52CADF0B77B044A0000000049454E44AE426082} end object bg: TStringGrid Left = 168 Top = 104 Width = 449 Height = 200 ColCount = 6 Ctl3D = False FixedCols = 0 RowCount = 4 ParentCtl3D = False TabOrder = 0 OnClick = Button1Click end object Button1: TButton Left = 640 Top = 440 Width = 75 Height = 25 Caption = 'Button1' TabOrder = 1 OnClick = Button1Click end end
标签:bg,Top,单元格,StringGrid1,Height,绘图,Font,rect,Left From: https://www.cnblogs.com/tulater/p/17977520