Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2014-02-02
3
Medium Priority
?
391 Views
Last Modified: 2014-02-02
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
Comment
Question by:Murray Brown
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 20

Accepted Solution

by:
TheAvenger earned 1000 total points
ID: 39827721
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
 
LVL 14

Assisted Solution

by:Matti
Matti earned 1000 total points
ID: 39827867
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
 

Author Closing Comment

by:Murray Brown
ID: 39827872
Thanks for the help
0

Featured Post

Independent Software Vendors: 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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

704 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question