VB6 MSFlexGrid - 合并列的 ColPos
我正在 VB6 中使用 MSFlexGrid 控件,但在检索合并列的 ColPos
属性时也遇到一些问题。我生成的网格看起来像这样:
-----------------------------
| 8/17/2010 |
-----------------------------
| Column 1 | Column 2 |
-----------------------------
第一行是固定的,两列被合并,因此两列在第一行中都包含 8/17/2010
。
在 Click
事件期间,我将文本框放置在第二行中的单元格上,并且当我设置其 Left
和 Top
属性时使用 FlexGrid 的 ColPos
和 RowPos
属性,我最终将文本框定位在第 1 列上方。即使我单击第 2 列,也会发生这种情况。
我检查了 Col
属性,单击第二列后它正确设置为 2,但是 ColPos(1)
和 ColPos(2) 都返回相同的值,即从第 1 列左边缘到控件左边缘的距离。
当在 FlexGrid 上禁用合并时,问题就会消失,但我宁愿保留它,因为它使网格更具可读性。
当列中的另一个单元格与另一个单元格合并时,有什么方法可以检索所选列的正确位置,或者我是否需要手动计算列位置?
I'm working with a MSFlexGrid control in VB6, but I'm also having some problems retrieving the ColPos
property for merged columns. The grid that I've generated looks something like this:
-----------------------------
| 8/17/2010 |
-----------------------------
| Column 1 | Column 2 |
-----------------------------
The first row is fixed and the two columns are merged, so both columns contain 8/17/2010
in the first row.
During the Click
event, I'm positioning a text box over a cell in the second row, and when I set its Left
and Top
properties using the FlexGrid's ColPos
and RowPos
properties, I end up with the textbox positioned over column 1. This happens even if I clicked in column 2.
I've checked the Col
property, and it's correctly set to 2 after clicking in the second column, but ColPos(1)
and ColPos(2)
both return the same value, which is the distance from column 1's left edge to the left edge of the control.
When merging is disabled on the flexgrid, the problem goes away, but I'd rather leave it on since it makes the grid a bit more readable.
Is there any way to retrieve the correct position of the selected column when another cell in the column is merged with another one, or do I need to calculate the column position manually?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
还没有找到通过控件来完成此操作的方法,但这是我组合在一起的一个函数,可以实现这一点。它从选定的单元格开始向后计数,直到到达与其合并的最左边的单元格,然后将合并单元格的宽度添加到第一个单元格的位置。可能可以清理一些,但这确实有效。
Haven't found a way to do it through the control, but here's a function that I put together that does the trick. It counts backward from the selected cell until it reaches the leftmost cell it's merged with, and then adds the widths of the merged cells to the first one's position. Probably could be cleaned up some, but this does work.