Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
225
How to move a WinGridRowEditTemplate control at runtime
posted

 Hi, I am trying to make it so that user can left click on a WinGridRowEditTemplate control to move it around just like he/she could with a form.  Is there any way to do that?

 I tried the following code and it works for other .NET controls (e.g. Button) but it doesn't seem to work for the WinGridRowEditTemplate control.

 

  Private _x As Integer
  Private _y As Integer
  Private Sub UltraGridRowEditTemplate1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles UltraGridRowEditTemplate1.MouseDown
    _x = e.X
    _y = e.Y
  End Sub

  Private Sub UltraGridRowEditTemplate1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles UltraGridRowEditTemplate1.MouseMove
    If e.Button = Windows.Forms.MouseButtons.Left Then
      UltraGridRowEditTemplate1.Left = UltraGridRowEditTemplate1.Left + e.X - _x
      UltraGridRowEditTemplate1.Top = UltraGridRowEditTemplate1.Top + e.Y - _y
    End If
  End Sub

  • 37774
    posted

    A much simpler way to do this would simply be to set the DialogSettings.ControlBox property of the template to True.  This will cause the underlying form that hosts the template to show its caption (the DialogSettings properties delegate to the Form).  If you really need to do this yourself, you will have to make adjustments to the Parent of the template and not the template itself.

    -Matt