AdvStringGrid 删除数据
Posted 不能富贵难成大器皆因懒, 胸无大志庸庸碌碌只为闲。
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了AdvStringGrid 删除数据相关的知识,希望对你有一定的参考价值。
unit Unit6; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, AdvUtil, Vcl.StdCtrls, Vcl.Grids, AdvObj, BaseGrid, AdvGrid; type TForm6 = class(TForm) AdvStringGrid1: TAdvStringGrid; btn1: TButton; btn2: TButton; btn4: TButton; btn5: TButton; btn6: TButton; procedure btn1Click(Sender: TObject); procedure btn2Click(Sender: TObject); procedure btn4Click(Sender: TObject); procedure AdvStringGrid1GetAlignment(Sender: TObject; ARow, ACol: Integer; var HAlign: TAlignment; var VAlign: TVAlignment); procedure btn5Click(Sender: TObject); procedure btn6Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form6: TForm6; implementation {$R *.dfm} procedure TForm6.AdvStringGrid1GetAlignment(Sender: TObject; ARow, ACol: Integer; var HAlign: TAlignment; var VAlign: TVAlignment); begin HAlign := taCenter; VAlign := vtaCenter; end; procedure TForm6.btn1Click(Sender: TObject); var i,j: Integer; begin AdvStringGrid1.WordWrap := False; AdvStringGrid1.Multilinecells := True; AdvStringGrid1.Cells[0, 1] := \'小李飞刀\'; AdvStringGrid1.Cells[1, 1] := \'1111111\'; AdvStringGrid1.Cells[2, 1] := \'2222222\'; AdvStringGrid1.Cells[0, 2] := \'小李飞刀\'; AdvStringGrid1.Cells[1, 2] := \'1111111\'; AdvStringGrid1.Cells[2, 2] := \'2222222\'; AdvStringGrid1.Cells[0, 3] := \'火云邪神\'; AdvStringGrid1.Cells[1, 3] := \'33333333\'; AdvStringGrid1.Cells[2, 3] := \'44444444\'; AdvStringGrid1.Cells[0, 4] := \'火云邪神\'; AdvStringGrid1.Cells[1, 4] := \'33333333\'; AdvStringGrid1.Cells[2, 4] := \'44444444\'; AdvStringGrid1.Cells[0, 5] := \'奥巴马\'; AdvStringGrid1.Cells[1, 5] := \'33333333\'; AdvStringGrid1.Cells[2, 5] := \'44444444\'; end; procedure TForm6.btn2Click(Sender: TObject); begin //清空N行数据(保留表格) AdvStringGrid1.ClearRows(1, AdvStringGrid1.RowCount - 1); end; procedure TForm6.btn4Click(Sender: TObject); begin //删除N行数据表格一并删除 AdvStringGrid1.RemoveRows(AdvStringGrid1.Row, 1); end; procedure TForm6.btn5Click(Sender: TObject); begin //全部清空数据clear(包括标题) AdvStringGrid1.Clear; end; procedure TForm6.btn6Click(Sender: TObject); begin //全部清空clearAll(包括标题-更深层次慎用-看源码) AdvStringGrid1.ClearAll; end; end.
以上是关于AdvStringGrid 删除数据的主要内容,如果未能解决你的问题,请参考以下文章