程序中使用TStringGrid中, 在OnDrawCell事件中报错如下:
E2015 Ambiguity between 'TGridDrawState' and 'Grids::TGridDrawState'
在网上搜索相关文章如下:
TGridDrawState名字空间冲突问题及解决方法 (老妖的文章)
http://community.csdn.net/Expert/TopicView3.asp?id=5400740
程序曾经出现以下信息
[C++ Error] audit.cpp(35): E2034 Cannot convert 'void (_fastcall * (_closure )(TObject *,int,int,TRect &,Grids::TGridDrawState))(TObject *,int,int,TRect &,Grids::TGridDrawState)' to 'void (_fastcall * (_closure )(TObject *,int,int,const TRect &,Grids::TGridDrawState))(TObject *,int,int,const TRect &,Grids::TGridDrawState)'
同时根据论坛方法StringGrid1->OnDrawCell = TDrawCellEvent(StringGrid1DrawCell);
最终还是出错提示:
[C++ Error] SystemMain.cpp(159): E2015 Ambiguity between 'TDrawCellEvent' and 'Grids::TDrawCellEvent'
后来在老妖的文章如何自画ListView的Item(XP效果) , 事件OnDrawItem指针ListView1->OnDrawItem =(TLVDrawItemEvent)&CrnDrawListViewItem得到启发;
public声明:
void __fastcall sgAlertDataDrawCell(TObject *Sender, int ACol,
int ARow, TRect &Rect, Grids::TGridDrawState State);
将事件指针改为SGridAlert->OnDrawCell = (Grids::TDrawCellEvent)&sgAlertDataDrawCell 编译通过并成功响应事件。