解决]VC:CDataGrid控件响应鼠标双击事件

CDataGrid部分函数功能说明:

GetRowHeight()得到行高

GetRow得到光标所在行的行号(看来,上面的计算是多余的了,直接调用它就可以得到鼠标点击的行号了)

GetCol得到光标所在列的列号

GetVisibleRows得到当前窗口显示的行数

GetFirstRow得到当前窗口第一行的绝对行号

.......

找到了,就是它!

以下是实现代码:
 try
 {
  int iRow=m_datagrid.GetRow();
  if (iRow<0)//点击的是列头
  {
   return;
  }

  int iCol=m_datagrid.GetCol();
  if (iCol>=0)//点击的不是行头
  {
   return;
  }

  VARIANT   IndexRow=m_datagrid.GetFirstRow();
  IndexRow.lVal+=iRow;
  
   VARIANT   IndexCol;  
   IndexCol.vt   =   VT_I4;  
   IndexCol.lVal   =   0;   //取第一列

  CString str=m_datagrid.GetColumns().GetItem(IndexCol).GetText();
  MessageBox(str);
 }
 catch(...)
 {
 }

 

在加上头文件#include "column.h"
#include "columns.h"

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值