Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 395
  • Last Modified:

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)
        {

        }

      }
}
0
Murray Brown
Asked:
Murray Brown
2 Solutions
 
TheAvengerCommented:
Change this:
Me.toolStrip1.LocationChanged = Sub(sender As Object, e As EventArgs) Me.panel1.Height = Me.toolStrip1.Top
    End Sub

Open in new window


To this:
AddHandler Me.toolStrip1.LocationChanged, Sub(sender As Object, e As EventArgs) Me.panel1.Height = Me.toolStrip1.Top
    End Sub

Open in new window

0
 
MattiCommented:
Hi!

try this http://www.icsharpcode.net/OpenSource/SD/Default.aspx

it even creates better .NET code than you if you do convert it back to vb.net
0
 
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Thanks for the help
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now