不错。我是加了个TEXTBOX,而且还在同一网格的右边加入一个COMMANDBUTTON,我希望用户在改变列宽以后,COMMANDBUTTON可以靠右对齐。

解决方案 »

  1.   

    当活动单元更改时,下列事件顺序发生:首先是 LeaveCell、接着是 EnterCell、最后是 RowColChange。当用户单击一个新的单元时 RowColChange 事件发生。用户拖动一个选择经过 MSHFlexGrid 时不发生。
      

  2.   

    ③用Timer控件来处理,在事件中比较当前列宽与原始值      [涛声依旧]只有以上方法有用。没有什么其他好办法了。
      

  3.   

    把MSHFlexGrid1的allowuserresizing置为false!!!
    然后在MSHFlexGrid1的mousedown事件中判断鼠标是否点在列与列的分隔线上
    如果是设置一个全局的标志,这个标志需要包含具体是那条分隔线的信息,
    然后你在mousemove里改变列宽
    在mouseup中把那个全局标志置回初始状态
      

  4.   

    在开始拖动的时候,你要把所有事件都由MSHFlexGrid1处理(为了防止鼠标跑到MSHFlexGrid1范围之外)你需要用到setcapture来控制
      

  5.   

    to:wjying(葡萄)   
       你有没有代码?
      

  6.   

    前面找了一下,那个关于setcapture,getcapture的贴子不知到跑哪儿去了,实在不好意思
    你有耐心就自己查msdn
    或者你可以找ljren_t(立志),记得我在论坛上看到的例子是由他提供的
      

  7.   

    to wjying(葡萄): 没有找到啊!
      

  8.   

    好想有:
    Private Sub VSFlexGrid1_AfterUserResize(ByVal Row As Long, ByVal Col As Long)End Sub
    这样的事件啊......
      

  9.   

    AfterUserResize有吗?我怎么没找到'关于setcapture的一个例子,你可以体会一下,原文在http://www.csdn.net/Expert/topic/473/473706.shtm
    Option ExplicitPrivate Declare Function SetCapture Lib "user32" (ByVal hWnd As Long) As Long
    Private Declare Function ReleaseCapture Lib "user32" () As Long
    Private Declare Function GetCapture Lib "user32" () As Long
    Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
    Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As LongPrivate Type POINTAPI
      x As Long
      y As Long
    End Type
    Private blnMouseIsIn As BooleanPrivate Sub cursorManager(x As Single, y As Single)
        Dim pointXY As POINTAPI
        Dim hWnd As Long
        Call GetCursorPos(pointXY)
        hWnd = WindowFromPoint(pointXY.x, pointXY.y)
        If (x > 0) And (x < Me.Width) And (y > 0) And (y < Me.Height) And (Me.hWnd = hWnd) Then
            If Not blnMouseIsIn Then
                blnMouseIsIn = True
                Debug.Print "In"
            End If
            If GetCapture <> Me.hWnd Then
              SetCapture Me.hWnd
            End If
        Else
            If blnMouseIsIn Then
                Debug.Print "out"
                ReleaseCapture
            End If
            blnMouseIsIn = False
        End If
    End Sub
    Private Sub Form_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
        Call cursorManager(x, y)
    End Sub
    'Private Sub Form_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
        'Call cursorManager(x, y)
    'End Sub
    Private Sub Form_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
        Call cursorManager(x, y)
    End Sub
      

  10.   

    I don't know too,but i can up.
      

  11.   

    用子类化在Wm_Size消息中处理,我做了一个Grid控件上面贴TextBox,就是这样处理让TExtbox与Grid列宽一起改变