首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ Builder >

TDBGrid控件OnCellClick事件中怎么根据TColumn参数获取对应的TDBGrid对象

2012-10-17 
TDBGrid控件OnCellClick事件中如何根据TColumn参数获取对应的TDBGrid对象C/C++ codevoid __fastcall TfmJl

TDBGrid控件OnCellClick事件中如何根据TColumn参数获取对应的TDBGrid对象

C/C++ code
void __fastcall TfmJlzlSPXdzl::RzDBGrid_WTCXCellClick(TColumn *Column){     this->ShowInfo(this->RzDBGrid_WTCX);}//---------------------------------------void __fastcall TfmJlzlSPXdzl::RzDBGrid_ZLCXCellClick(TColumn *Column){    this->ShowInfo(this->RzDBGrid_ZLCX);}void __fastcall TfmJlzlSPXdzl::ShowInfo(TRzDBGrid* sqlgrid){   AnsiString fieldname,fieldvalue;   for(int i=0;i<sqlgrid->FieldCount;i++)   {      fieldname = sqlgrid->Fields[i]->FieldName.LowerCase();      fieldvalue = sqlgrid->Fields[i]->Text;      if(fieldname == "zjmc")      {      this->Rzedt_ZJMC->Text = fieldvalue;}      else if(fieldname == "zqmc")      {      this->Rzedt_ZQMC->Text = fieldvalue;}   }}

我想根据TColumn参数获取对应的TDBGrid对象修改为如下代码
C/C++ code
void __fastcall TfmJlzlSPXdzl::FormCreate(TObject *Sender){    this->RzDBGrid_WTCX->OnCellClick =  RzDBGrid_CellClick;    this->RzDBGrid_ZLCX->OnCellClick =  RzDBGrid_CellClick;}void __fastcall TfmJlzlSPXdzl::RzDBGrid_CellClick(TColumn *Column){        //这里使用TColumn参数获取对应的TDBGrid对象调用ShowInfo函数}


[解决办法]
Column->Grid

热点排行