110,565
社区成员
发帖
与我相关
我的任务
分享
你这样做究竟有什么目的? 说出你的最终目的,看看有没有其他手段. 不要为了目的不择手段,为了手段忘记目的.
楼主这样做目的是什么呢? 走EXCEL6下的消息通道可以拿到光标的位置,这个位置跟字体大小,中西文字符有关,不过你拿到这个位置貌似也没什么用。 [DllImport("user32.dll"] public static extern bool GetCaretPos(ref System.Drawing.Point lpPoint); 在消息WM_LBUTTONUP,WM_KEYUP里面调用上面API获取就可以。
这个 得到的是 单元格的 行列,不是在编辑状态下那个excel6的编辑框里光标的位置,所以没用呢。
参考: How to get current or focussed cell value in Excel worksheet using C# Microsoft Office Excel Programming Using VSTO 3.0 你这是C#的代码吗?如果用VSTO做的话,下面的代码获取当前单元格,及行号列号以及内容Excel.Range rng = (Excel.Range) this.Application.ActiveCell; //get the cell value object cellValue = rng.Value; //get the row and column details int row = rng.Row; int column = rng.Column;
Excel.Range rng = (Excel.Range) this.Application.ActiveCell;
//get the cell value
object cellValue = rng.Value;
//get the row and column details
int row = rng.Row;
int column = rng.Column;
http://club.excelhome.net/thread-102466-1-1.html