Link to home
Start Free TrialLog in
Avatar of Murray Brown
Murray BrownFlag for United Kingdom of Great Britain and Northern Ireland

asked on

VB.net Error in convering code behind a form from C# to VB.net

Hi

I am trying to convert the C# code at the bottom to the VB.net code just above.
I have one error at the line:
  Me.toolStrip1.LocationChanged = Sub(sender As Object, e As EventArgs) Me.panel1.Height = Me.toolStrip1.Top
The error is
Error      1      'Public Event LocationChanged(sender As Object, e As System.EventArgs)' is an event, and cannot be called directly. Use a 'RaiseEvent' statement to raise an event.      C:\Users\murbro\documents\visual studio 2010\Projects\Infra_WinForms\Infra_WinForms\Form1.vb      22      9      Infra_WinForms



Imports System.Drawing
Imports System.Windows.Forms

Public Class Form1

    Public Sub New()
        InitializeComponent()

        ' Make your controls movable by a mouseclick
        Helper.ControlMover.Init(Me.button1)
        Helper.ControlMover.Init(Me.checkBox1)
        Helper.ControlMover.Init(Me.groupBox1)
        Helper.ControlMover.Init(Me.textBox1)
        Helper.ControlMover.Init(Me.label1)

        ' Move a panel by its toolstrip
        Helper.ControlMover.Init(Me.toolStrip2, Me.panel3, Helper.ControlMover.Direction.Any)

        ' Make a splitter from toolstrip
        Helper.ControlMover.Init(Me.toolStrip1, Helper.ControlMover.Direction.Vertical)
        Me.toolStrip1.LocationChanged = Sub(sender As Object, e As EventArgs) Me.panel1.Height = Me.toolStrip1.Top
    End Sub

   
End Class

using System;
using System.Drawing;
using System.Windows.Forms;

namespace MoveYourControls
{
      public partial class Form1 : Form
      {
            public Form1()
            {
                  InitializeComponent();

                  // Move your controls
                  Helper.ControlMover.Init(this.button1);
                  Helper.ControlMover.Init(this.checkBox1);
                  Helper.ControlMover.Init(this.groupBox1);
                  Helper.ControlMover.Init(this.textBox1);
                  Helper.ControlMover.Init(this.label1);

                  // Move a panel by its toolstrip
                  Helper.ControlMover.Init(this.toolStrip2, this.panel3, Helper.ControlMover.Direction.Any);

                  // Make a splitter from toolstrip
                  Helper.ControlMover.Init(this.toolStrip1, Helper.ControlMover.Direction.Vertical);
                  this.toolStrip1.LocationChanged += delegate(object sender, EventArgs e)
                  {
                        this.panel1.Height = this.toolStrip1.Top;
                  };
            }

        private void button1_Click(object sender, EventArgs e)
        {

        }

      }
}
ASKER CERTIFIED SOLUTION
Avatar of TheAvenger
TheAvenger
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Murray Brown

ASKER

Thanks for the help