DBGRID的多选问题?请和位大侠帮忙!!! 将options的dgMultiselect := True 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 //pasunit Unit1;interfaceuses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Db, DBTables, Grids, DBGrids;type TForm1 = class(TForm) DBGrid1: TDBGrid; DataSource1: TDataSource; Table1: TTable; procedure DBGrid1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); procedure DBGrid1KeyUp(Sender: TObject; var Key: Word; Shift: TShiftState); procedure DataSource1DataChange(Sender: TObject; Field: TField); private { Private declarations } FKeyShift: Boolean; public { Public declarations } end;var Form1: TForm1;implementation{$R *.DFM}procedure TForm1.DBGrid1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);begin FKeyShift := ssShift in Shift;end;procedure TForm1.DBGrid1KeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);begin FKeyShift := False;end;procedure TForm1.DataSource1DataChange(Sender: TObject; Field: TField);begin if FKeyShift then DBGrid1.SelectedRows.CurrentRowSelected := True; FKeyShift := False;end;end.//dfmobject Form1: TForm1 Left = 192 Top = 107 Width = 544 Height = 287 Caption = 'Form1' Color = clBtnFace Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -11 Font.Name = 'MS Sans Serif' Font.Style = [] OldCreateOrder = False PixelsPerInch = 96 TextHeight = 13 object DBGrid1: TDBGrid Left = 0 Top = 0 Width = 536 Height = 260 Align = alClient DataSource = DataSource1 Options = [dgTitles, dgIndicator, dgColumnResize, dgColLines, dgRowLines, dgTabs, dgRowSelect, dgConfirmDelete, dgCancelOnExit, dgMultiSelect] TabOrder = 0 TitleFont.Charset = DEFAULT_CHARSET TitleFont.Color = clWindowText TitleFont.Height = -11 TitleFont.Name = 'MS Sans Serif' TitleFont.Style = [] OnKeyDown = DBGrid1KeyDown OnKeyUp = DBGrid1KeyUp end object DataSource1: TDataSource DataSet = Table1 OnDataChange = DataSource1DataChange Left = 112 Top = 8 end object Table1: TTable Active = True DatabaseName = '我不知道你的库名' TableName = '我不知道你的表名' Left = 144 Top = 8 endend quickreport,adotable,设计时预览可以但是运行时调用QuickRep1.Preview出错:Invalid variant type conversion SQL中数据库多文件的问题: sql: 如何计算字段下不同的数值有几条记录?有很多字段。 webbrowser 怎么判断页面下没下载完? Access转换格式 delphi里有没有日期间隔函数啊? 如何定制TChart.Title? 两个控件安装的问题 dll 判断其它应用程序菜单项的状态。 使用batchmove控件的问题: 请问有没有与PING效果类似的方法或控件?
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Db, DBTables, Grids, DBGrids;type
TForm1 = class(TForm)
DBGrid1: TDBGrid;
DataSource1: TDataSource;
Table1: TTable;
procedure DBGrid1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure DBGrid1KeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure DataSource1DataChange(Sender: TObject; Field: TField);
private
{ Private declarations }
FKeyShift: Boolean;
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.DFM}procedure TForm1.DBGrid1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
FKeyShift := ssShift in Shift;
end;procedure TForm1.DBGrid1KeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
FKeyShift := False;
end;procedure TForm1.DataSource1DataChange(Sender: TObject; Field: TField);
begin
if FKeyShift then DBGrid1.SelectedRows.CurrentRowSelected := True;
FKeyShift := False;
end;end.//dfm
object Form1: TForm1
Left = 192
Top = 107
Width = 544
Height = 287
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object DBGrid1: TDBGrid
Left = 0
Top = 0
Width = 536
Height = 260
Align = alClient
DataSource = DataSource1
Options = [dgTitles, dgIndicator, dgColumnResize, dgColLines, dgRowLines, dgTabs, dgRowSelect, dgConfirmDelete, dgCancelOnExit, dgMultiSelect]
TabOrder = 0
TitleFont.Charset = DEFAULT_CHARSET
TitleFont.Color = clWindowText
TitleFont.Height = -11
TitleFont.Name = 'MS Sans Serif'
TitleFont.Style = []
OnKeyDown = DBGrid1KeyDown
OnKeyUp = DBGrid1KeyUp
end
object DataSource1: TDataSource
DataSet = Table1
OnDataChange = DataSource1DataChange
Left = 112
Top = 8
end
object Table1: TTable
Active = True
DatabaseName = '我不知道你的库名'
TableName = '我不知道你的表名'
Left = 144
Top = 8
end
end