Home Database Mysql Tutorial AdvStringGrid使用方法(2)

AdvStringGrid使用方法(2)

Jun 07, 2016 pm 03:43 PM
Instructions

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

  1. procedure TForm1.FormCreate(Sender: TObject);
  2. begin
  3.   AdvStringGrid1.FixedRows:=2;
  4.   AdvStringGrid1.SaveFixedCells := false;
  5.   AdvStringGrid1.MergeCells(1,0,2,1);
  6.   AdvStringGrid1.MergeCells(3,0,2,1);
  7.   AdvStringGrid1.Cells[1,0] := '

     Identification

    '
    ;
  8.   AdvStringGrid1.Cells[1,1] := 'Brand';
  9.   AdvStringGrid1.Cells[2,1] := 'Type';
  10.   AdvStringGrid1.Cells[3,1] := 'CC';
  11.   AdvStringGrid1.Cells[4,1] := 'Pk';
  12.   AdvStringGrid1.Cells[3,0] := '

    Power

    '
    ;
  13.   AdvStringGrid1.BtnEdit.ButtonWidth := 24;
  14. end;
 一、Navigation——AdvancelInsert:控制当光标在最后一个CELL时是否可以按回车插入新行

二、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):

  1. procedure Tfrm_dingdan.strgridGetCellColor(Sender: TObject; ARow, 
  2.   ACol: Integer; AState: TGridDrawState; ABrush: TBrush; AFont: TFont); 
  3. begin 
  4.   if ARow=0 then     //如果不加这一句,则是以下对应的整列,我这里是只改变固列,所以要把ARow设为0 
  5.     begin 
  6.       Case ACol of 
  7.         1: ABrush.Color:=RGB(227,249,248); 
  8.         2: ABrush.Color:=RGB(250,232,193); 
  9.         3: ABrush.Color:=RGB(227,249,248); 
  10.         4: ABrush.Color:=RGB(250,232,193); 
  11.         12: ABrush.Color:=RGB(227,249,248); 
  12.         14: ABrush.Color:=RGB(250,232,193); 
  13.         24: ABrush.Color:=RGB(227,249,248); 
  14.         48: ABrush.Color:=RGB(250,232,193); 
  15.         51: ABrush.Color:=RGB(227,249,248); 
  16.       End; 
  17.     END; 
  18. end; 

十四、如果在录入的过程中,要对某列做格式化,比如保留几位小数,可用ADVStringGrid的GetFloatFormat事件中操作。比如:

  1. procedure Tfrm_dingdan.strgridGetFloatFormat(Sender: TObject; ACol, 
  2.   ARow: Integer; var IsFloat: Boolean; var FloatFormat: String); 
  3. begin 
  4.   case ACol of 
  5.     4: floatformat:='%.0f';     //第4列保留0位小数 
  6.     5: floatformat:='%.3f';     //第5列保留3位小数 
  7.     6: floatformat:='%.6f';    //第6列保留6位小数 
  8.     7: floatformat:='%.5f';    //第7列保留5位小数 
  9.   end; 
  10. 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事件中加入
 

  1.  for i:=1 to advstringgrid.rowcount-1 do
  2.     advstringgrid.AddCheckBox(1,i,false,false);   //其中1表示所在列数
  3.    GetCheckBoxState(col,row) 可以查询的
  4.    Bchek:Boolean;
  5.    AdvSGrid.GetCheckBoxState(Col,Arow,Bchek);

---------------------------------------------------------------------
4、stringGrid中的行或列和并
 

  1.   grdList.MergeCells(0,0,2,2);
  2.    grdList.Cells[0,0]:='123456';
  3.    advstringgrid.mergecol(3,4);
  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;

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to use DirectX repair tool? Detailed usage of DirectX repair tool How to use DirectX repair tool? Detailed usage of DirectX repair tool Mar 15, 2024 am 08:31 AM

The DirectX repair tool is a professional system tool. Its main function is to detect the DirectX status of the current system. If an abnormality is found, it can be repaired directly. There may be many users who don’t know how to use the DirectX repair tool. Let’s take a look at the detailed tutorial below. 1. Use repair tool software to perform repair detection. 2. If it prompts that there is an abnormal problem in the C++ component after the repair is completed, please click the Cancel button, and then click the Tools menu bar. 3. Click the Options button, select the extension, and click the Start Extension button. 4. After the expansion is completed, re-detect and repair it. 5. If the problem is still not solved after the repair tool operation is completed, you can try to uninstall and reinstall the program that reported the error.

Introduction to HTTP 525 status code: explore its definition and application Introduction to HTTP 525 status code: explore its definition and application Feb 18, 2024 pm 10:12 PM

Introduction to HTTP 525 status code: Understand its definition and usage HTTP (HypertextTransferProtocol) 525 status code means that an error occurred on the server during the SSL handshake, resulting in the inability to establish a secure connection. The server returns this status code when an error occurs during the Transport Layer Security (TLS) handshake. This status code falls into the server error category and usually indicates a server configuration or setup problem. When the client tries to connect to the server via HTTPS, the server has no

How to use Baidu Netdisk-How to use Baidu Netdisk How to use Baidu Netdisk-How to use Baidu Netdisk Mar 04, 2024 pm 09:28 PM

Many friends still don’t know how to use Baidu Netdisk, so the editor will explain how to use Baidu Netdisk below. If you are in need, hurry up and take a look. I believe it will be helpful to everyone. Step 1: Log in directly after installing Baidu Netdisk (as shown in the picture); Step 2: Then select "My Sharing" and "Transfer List" according to the page prompts (as shown in the picture); Step 3: In "Friend Sharing", you can share pictures and files directly with friends (as shown in the picture); Step 4: Then select "Share" and then select computer files or network disk files (as shown in the picture); Fifth Step 1: Then you can find friends (as shown in the picture); Step 6: You can also find the functions you need in the "Function Treasure Box" (as shown in the picture). The above is the editor’s opinion

Learn to copy and paste quickly Learn to copy and paste quickly Feb 18, 2024 pm 03:25 PM

How to use the copy-paste shortcut keys Copy-paste is an operation we often encounter when using computers every day. In order to improve work efficiency, it is very important to master the copy and paste shortcut keys. This article will introduce some commonly used copy and paste shortcut keys to help readers perform copy and paste operations more conveniently. Copy shortcut key: Ctrl+CCtrl+C is the shortcut key for copying. By holding down the Ctrl key and then pressing the C key, you can copy the selected text, files, pictures, etc. to the clipboard. To use this shortcut key,

What is the KMS activation tool? How to use the KMS activation tool? How to use KMS activation tool? What is the KMS activation tool? How to use the KMS activation tool? How to use KMS activation tool? Mar 18, 2024 am 11:07 AM

The KMS Activation Tool is a software tool used to activate Microsoft Windows and Office products. KMS is the abbreviation of KeyManagementService, which is key management service. The KMS activation tool simulates the functions of the KMS server so that the computer can connect to the virtual KMS server to activate Windows and Office products. The KMS activation tool is small in size and powerful in function. It can be permanently activated with one click. It can activate any version of the window system and any version of Office software without being connected to the Internet. It is currently the most successful and frequently updated Windows activation tool. Today I will introduce it Let me introduce to you the kms activation work

How to correctly use the win10 command prompt for automatic repair operations How to correctly use the win10 command prompt for automatic repair operations Dec 30, 2023 pm 03:17 PM

The longer the computer is used, the more likely it is to malfunction. At this time, friends need to use their own methods to repair it. So what is the easiest way to do it? Today I will bring you a tutorial on how to repair using the command prompt. How to use win10 automatic repair command prompt: 1. Press "Win+R" and enter cmd to open the "command prompt" 2. Enter chkdsk to view the repair command 3. If you need to view other places, you can also add other partitions such as "d" 4. Enter the execution command chkdskd:/F. 5. If it is occupied during the modification process, you can enter Y to continue.

How to use Xiaoma win7 activation tool - How to use Xiaoma win7 activation tool How to use Xiaoma win7 activation tool - How to use Xiaoma win7 activation tool Mar 04, 2024 pm 06:16 PM

I believe that many users are using the Xiaoma win7 activation tool, but do you know how to use the Xiaoma win7 activation tool? Then, the editor will bring you how to use the Xiaoma win7 activation tool. For those who are interested in this, please come to the following article Let's see. The first step is to go to "My Computer" after reinstalling the system, click "System Properties" in the upper menu, and check the Windows activation status. In the second step, click to download the win7 activation tool online and click to open it (there are many resources available everywhere). The third step is to open the Xiaoma activation tool and click "Activate Windows permanently". The fourth step is to wait for the activation process to complete activation. Step 5: Check the Windows activation status again and find that the system has been activated.

What is PyCharm? Function introduction and detailed explanation of usage What is PyCharm? Function introduction and detailed explanation of usage Feb 20, 2024 am 09:21 AM

PyCharm is a professional Python integrated development environment (IDE) developed by JetBrains. It provides Python developers with powerful functions and tools, making writing Python code more efficient and convenient. PyCharm supports multiple operating systems, including Windows, macOS and Linux, and also supports multiple Python versions, and provides a wealth of plug-ins and extension functions to facilitate developers to customize the IDE environment according to their own needs. P

See all articles