用系统变量APPLICATION可以解决的!
解决方案 »
- delphi7操作excel2003出现:EIntfcasterror ‘interface not supported’
- 谁有兴趣用DELPHI实现一个C++那样的模板类
- 如何通过像QQ一样抓屏获取运行中的窗体的控件信息,包括名称、类型等。
- 请教一个Delphi与foxpro数据库的删除问题,高手帮帮忙啊!!分不够再加
- 求助,一个TreeView的问题.....
- 如何用类的继承来实现这个输入检测
- string如何转化为TFieldType?
- 上哪有24位真彩图(bmp)
- 大家帮忙。怎样控制系统声音的主音量。(我是新手)谢谢。来者有分:)
- 那里有跟操作“DateTimePicker“一样的能操作“时间的“ 控件
- 如何进行汉字转换?
- 高分相求,请高手帮忙,关于ActiveX问题。
if TDBGrid(ActiveControl)=
通过TDBGrid(ActiveControl)可以取得当前的dbgrid
TDBGrid(Sender).Name
PROCEDURE WP_FY(DBG:TDbgrid);
调用时如何自动读取当前dbgrid的名字
wp_fy();//这里要如何写?
begin
Result := DBG.Name;
end;//orprocedure wp_fy(DBG: TDBGrid);
begin
{用DBG.Name};
end;
(Sender as TDbGrid).Name可取回当前grid的name
procedure TOU_FOR.DBGrid1ColExit(Sender: TObject);
begin
if DBGrid1.SelectedField.Name='LS_SJ_TB1XJ' then //(这里需要改为DBGRID1、2、3)
....
end;
名称 =(Sender as TDBGrid).Name
If (Sender as TDBGrid).SelectedField.Name = 'LS_SJ_TB1XJ' then
就行了
if (ActiveControl is TDBGrid) then wp_fy(TDBGrid(ActiveControl))
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DB, DBTables, Grids, DBGrids;type
TForm1 = class(TForm)
DataSource1: TDataSource;
DBGrid1: TDBGrid;
DataSource2: TDataSource;
DataSource3: TDataSource;
DBGrid2: TDBGrid;
DBGrid3: TDBGrid;
Table1: TTable;
procedure Button1Click(Sender: TObject);
procedure DBGrid1ColExit(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
begin
Caption := Format('%-.5d', [1]);
end;procedure TForm1.DBGrid1ColExit(Sender: TObject);
begin
ShowMessage(TDBGrid(Sender).SelectedField.FieldName);
//~~~~~~~~~
end;end.//dfm
object Form1: TForm1
Left = 192
Top = 107
Width = 544
Height = 375
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 = 8
Width = 177
Height = 193
DataSource = DataSource1
TabOrder = 0
TitleFont.Charset = DEFAULT_CHARSET
TitleFont.Color = clWindowText
TitleFont.Height = -11
TitleFont.Name = 'MS Sans Serif'
TitleFont.Style = []
OnColExit = DBGrid1ColExit
end
object DBGrid2: TDBGrid
Left = 176
Top = 8
Width = 177
Height = 193
DataSource = DataSource1
TabOrder = 1
TitleFont.Charset = DEFAULT_CHARSET
TitleFont.Color = clWindowText
TitleFont.Height = -11
TitleFont.Name = 'MS Sans Serif'
TitleFont.Style = []
OnColExit = DBGrid1ColExit
end
object DBGrid3: TDBGrid
Left = 352
Top = 8
Width = 177
Height = 193
DataSource = DataSource1
TabOrder = 2
TitleFont.Charset = DEFAULT_CHARSET
TitleFont.Color = clWindowText
TitleFont.Height = -11
TitleFont.Name = 'MS Sans Serif'
TitleFont.Style = []
OnColExit = DBGrid1ColExit
end
object DataSource1: TDataSource
DataSet = Table1
Left = 8
Top = 24
end
object DataSource2: TDataSource
DataSet = Table1
Left = 200
Top = 24
end
object DataSource3: TDataSource
DataSet = Table1
Left = 384
Top = 24
end
object Table1: TTable
Active = True
DatabaseName = 'DBDEMOS'
TableName = 'animals.dbf'
Left = 232
Top = 248
end
end
if (ActiveControl is TDBGrid) then wp_fy(TDBGrid(ActiveControl))
//TDBGrid(ActiveControl)为dbgrid1、2、3,传入了要处理的dbgrid
//然后在wp_fy过程中处理
if DBG=Dbgrid1 then...
else if DBG=Dbgrid2 then...
else...