procedureTForm1.FormCreate(Sender:TObject); begin AdvStringGrid1.FixedRows:=2; AdvStringGrid1.SaveFixedCells:= false ; AdvStringGrid1.MergeCells(1,0,2,1); AdvStringGrid1.MergeCells(3,0,2,1); AdvStringGrid1.Cells[1,0]:= 'palign="center"bIde
- procedure TForm1.FormCreate(Sender: TObject);
- begin
- AdvStringGrid1.FixedRows:=2;
- AdvStringGrid1.SaveFixedCells := false;
- AdvStringGrid1.MergeCells(1,0,2,1);
- AdvStringGrid1.MergeCells(3,0,2,1);
-
AdvStringGrid1.Cells[1,0] := '
Identification
'; - AdvStringGrid1.Cells[1,1] := 'Brand';
- AdvStringGrid1.Cells[2,1] := 'Type';
- AdvStringGrid1.Cells[3,1] := 'CC';
- AdvStringGrid1.Cells[4,1] := 'Pk';
-
AdvStringGrid1.Cells[3,0] := '
Power
'; - AdvStringGrid1.BtnEdit.ButtonWidth := 24;
- end;
二、Navigation——AdvanceOnEnter:控制按回车是否自动移到下一个CELL
三、Navigation——AllowDeleteRow:控制是否按DELETE键删除当前行
四、Navigation——AppendOnArrowDown:控制按下箭头是否可以新增一行
五、EnableWheel:=true时,一次滚动多行,EnableWheel:=False时,一次滚动一行。
六、SearchFooter—Visible:=TRUE时,会在ADVStringGrid的底部显示出搜索框
七、Options—goTabs:控制是否可用TAB键将光标移到下一CELL
八、AutoNumAlign:=True则数字类型数据在CELL里会自动右对齐
九、ADVStringGrid.AutoNumberCol(0);表示第0列按顺序显示数字,即1,2,3……
十、FloatingFooter—Visible:为TRUE时,即在ADVStringGrid底部显示求和列,要想让求和列显示小数,还需要将FloatFormat属性设置为:%g
十一、当合并行后,如果想使文字垂直居中,可以先设置ADVStringGrid的 MultilineCells 设置为 True,然后在文字前面加 #13 换行来实行
十二、改变固定列的显示样式:ControlLook——FixedGradientFrom(起始色)——FixedGradientFrom(结束色)
十三、改变单元格的背景色,可在OnGetCellColor事件中写代码实行(前提需将FLAT设置为TRUE):
- procedure Tfrm_dingdan.strgridGetCellColor(Sender: TObject; ARow,
- ACol: Integer; AState: TGridDrawState; ABrush: TBrush; AFont: TFont);
- begin
- if ARow=0 then //如果不加这一句,则是以下对应的整列,我这里是只改变固列,所以要把ARow设为0
- begin
- Case ACol of
- 1: ABrush.Color:=RGB(227,249,248);
- 2: ABrush.Color:=RGB(250,232,193);
- 3: ABrush.Color:=RGB(227,249,248);
- 4: ABrush.Color:=RGB(250,232,193);
- 12: ABrush.Color:=RGB(227,249,248);
- 14: ABrush.Color:=RGB(250,232,193);
- 24: ABrush.Color:=RGB(227,249,248);
- 48: ABrush.Color:=RGB(250,232,193);
- 51: ABrush.Color:=RGB(227,249,248);
- End;
- END;
- end;
十四、如果在录入的过程中,要对某列做格式化,比如保留几位小数,可用ADVStringGrid的GetFloatFormat事件中操作。比如:
- procedure Tfrm_dingdan.strgridGetFloatFormat(Sender: TObject; ACol,
- ARow: Integer; var IsFloat: Boolean; var FloatFormat: String);
- begin
- case ACol of
- 4: floatformat:='%.0f'; //第4列保留0位小数
- 5: floatformat:='%.3f'; //第5列保留3位小数
- 6: floatformat:='%.6f'; //第6列保留6位小数
- 7: floatformat:='%.5f'; //第7列保留5位小数
- end;
- end;
十五、Options—goRangeSelect:控制是否可以选择多行,goRowSelect控制选中整行
、AdvStringGrid做多表头
在onIsFixedCell事件中返回true的就是表头
--------------------------------------------------------------------
2、怎样实现AdvStringGrid的列宽自动按内容调整?
怎样实现AdvStringGrid的列宽自动按列标题宽度调整?
autosize属性的作用是什么?
autosize,可以根据内容调整列宽。
自动按标题列调整,自己在其RESIZE事件里对COLWIDTHS[I]赋值就行了。
procedure AutoSizeColumns(const DoFixedCols: Boolean; const Padding: Integer);
例:AdvStringGrid1.AutoSizeColumns(False,16);
AdvStringGrid1.AutoSizeColumns(False,16);
第一参数:是否为固定列;第二个参数,文字后面留的空格数
所有单元格自动调整,由第一个参数设置是否含固定单元,
如要固定行折行显示应将其行高设为自动调整即:
AdvStringGrid1.AutoSizeRow(0);
---------------------------------------------------------------------
3、AdvStringGrid插入checkbox列
把advstringgrid的option属性中的goEditing 设为true
在from create事件中加入
- for i:=1 to advstringgrid.rowcount-1 do
- advstringgrid.AddCheckBox(1,i,false,false); //其中1表示所在列数
- GetCheckBoxState(col,row) 可以查询的
- Bchek:Boolean;
- AdvSGrid.GetCheckBoxState(Col,Arow,Bchek);
---------------------------------------------------------------------
4、stringGrid中的行或列和并
- grdList.MergeCells(0,0,2,2);
- grdList.Cells[0,0]:='123456';
- advstringgrid.mergecol(3,4);
- advstringgrid..MergeCells(0,0,2,2);
5、
with advStringGrid1 do //引用单元格时, 列数在前,行数在后.
MergeCells(0,0,1,3);
//合并单元格.前两参数为列数行数. 后两参数分别为要合并的列数和行数
Cells[1,0] := Format('分度线( %s )',[m_sMeasureRangeUnit]);;
MergeCells(3,JieDianStart - 1,1,1);
Cells[3,JieDianStart - 1] := '动作方式';
ColWidths[3] := ColWidths[3] + 10;
Colors[3,JieDianStart - 1] := FixedColor;
FontNames[3,JieDianStart - 1] := FixedFont.Name;
FontSizes[3,JieDianStart - 1] := FixedFont.Size;
FontStyles[3,JieDianStart - 1] := FixedFont.Style;
前面是我在程序中拉的一段.
控件常用事件:
//单元格可否被修改
onCanEditCell(Sender: TObject; ARow, ACol: Integer; var CanEdit: Boolean);
begin
if ACol = 0 then
CanEdit := false; //false不能修改
end;
//对齐方式
onGetAlignment(Sender: TObject; ARow,
ACol: Integer; var HAlign: TAlignment; var VAlign: TVAlignment);
begin
HAlign := taCenter;
VAlign := vtaCenter;
end;
//是否固定列 ,即标题列, 在表中非开头行需要固定标题列时很有用
onIsFixedCell(Sender: TObject; ARow,
ACol: Integer; var IsFixed: Boolean);
begin
if(ARow = 10) then
begin
IsFixed := True;
end;
end;
-------------------------------------------------------------------------------
6、如何在AdvStringGrid中为每个单元格内的字体定制颜色
在OnDrawCell事件(看名字这个控件应该有这个事件把,呵呵!)写如下代码:
(Sender as TAdvStringGrid).Canvas.Font.Color:=clNavy;
7、cell中内嵌combobox
OnGetEditorType事件
if ACol = 1 then
begin
aEditor := edComboList;
grdMain.ClearComboString;
grdMain.AddComboString('借');
grdMain.AddComboString(' 贷');
end;

InnoDBBufferPool reduces disk I/O by caching data and indexing pages, improving database performance. Its working principle includes: 1. Data reading: Read data from BufferPool; 2. Data writing: After modifying the data, write to BufferPool and refresh it to disk regularly; 3. Cache management: Use the LRU algorithm to manage cache pages; 4. Reading mechanism: Load adjacent data pages in advance. By sizing the BufferPool and using multiple instances, database performance can be optimized.

Compared with other programming languages, MySQL is mainly used to store and manage data, while other languages such as Python, Java, and C are used for logical processing and application development. MySQL is known for its high performance, scalability and cross-platform support, suitable for data management needs, while other languages have advantages in their respective fields such as data analytics, enterprise applications, and system programming.

MySQL is worth learning because it is a powerful open source database management system suitable for data storage, management and analysis. 1) MySQL is a relational database that uses SQL to operate data and is suitable for structured data management. 2) The SQL language is the key to interacting with MySQL and supports CRUD operations. 3) The working principle of MySQL includes client/server architecture, storage engine and query optimizer. 4) Basic usage includes creating databases and tables, and advanced usage involves joining tables using JOIN. 5) Common errors include syntax errors and permission issues, and debugging skills include checking syntax and using EXPLAIN commands. 6) Performance optimization involves the use of indexes, optimization of SQL statements and regular maintenance of databases.

MySQL is suitable for beginners to learn database skills. 1. Install MySQL server and client tools. 2. Understand basic SQL queries, such as SELECT. 3. Master data operations: create tables, insert, update, and delete data. 4. Learn advanced skills: subquery and window functions. 5. Debugging and optimization: Check syntax, use indexes, avoid SELECT*, and use LIMIT.

MySQL efficiently manages structured data through table structure and SQL query, and implements inter-table relationships through foreign keys. 1. Define the data format and type when creating a table. 2. Use foreign keys to establish relationships between tables. 3. Improve performance through indexing and query optimization. 4. Regularly backup and monitor databases to ensure data security and performance optimization.

MySQL is an open source relational database management system that is widely used in Web development. Its key features include: 1. Supports multiple storage engines, such as InnoDB and MyISAM, suitable for different scenarios; 2. Provides master-slave replication functions to facilitate load balancing and data backup; 3. Improve query efficiency through query optimization and index use.

SQL is used to interact with MySQL database to realize data addition, deletion, modification, inspection and database design. 1) SQL performs data operations through SELECT, INSERT, UPDATE, DELETE statements; 2) Use CREATE, ALTER, DROP statements for database design and management; 3) Complex queries and data analysis are implemented through SQL to improve business decision-making efficiency.

The basic operations of MySQL include creating databases, tables, and using SQL to perform CRUD operations on data. 1. Create a database: CREATEDATABASEmy_first_db; 2. Create a table: CREATETABLEbooks(idINTAUTO_INCREMENTPRIMARYKEY, titleVARCHAR(100)NOTNULL, authorVARCHAR(100)NOTNULL, published_yearINT); 3. Insert data: INSERTINTObooks(title, author, published_year)VA


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

SublimeText3 Linux new version
SublimeText3 Linux latest version

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

Dreamweaver CS6
Visual web development tools