VB code translated to C#.

Posted on 2011-09-20
Last Modified: 2013-12-17

I have found code to resize a borderless form.
But the code is in VB! So I use this site:
to convert the code to C#.

After testing it there is one little problem ( i hope i explain this right):

After I have resized the form and let go of the mouse-button
the edge of the form is still attached to the mouse-cursor. So
even do I let go of the mouse-button I still can resize the form.
I have to click it twice before it actually let go.

I have tested the VB-version and that works great.

Does someone knows the anser and is willing to help me?


Peter Kiers
Question by:peterkiers
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
  • 2
LVL 15

Accepted Solution

x77 earned 500 total points
ID: 36569512
Vb uses WithEvent Clause when Declare Buttons and Panel.
This Generates some internal properties to set EventHandlers.

You need add Handlers to Buttons and Panel as converter do´nt make it.

You omit also methods from buttons
public StickyNotes()
            MouseMove += StickyNotes_MouseMove;
            MouseDown += StickyNotes_MouseDown;

            this.btnClose.Click += btnClose_Click;
            this.btnMaximize.Click += btnMaximize_Click;
            this.btnMinimize.Click += this.btnMinimize_Click;
            this.pnlCaption.MouseMove += pnlCaption_MouseMove;
            this.pnlCaption.MouseDown += pnlCaption_MouseDown;
        private void pnlCaption_MouseDown(object sender, MouseEventArgs e)
            if ((e.Button == MouseButtons.Left) & (this.WindowState != FormWindowState.Maximized))
        private void pnlCaption_MouseMove(object sender, MouseEventArgs e)
            this.resizeDir = ResizeDirection.None;
        private void btnClose_Click(object sender, EventArgs e)
        private void btnMinimize_Click(object sender, EventArgs e)
            this.WindowState = FormWindowState.Minimized;
        private void btnMaximize_Click(object sender, EventArgs e)
            if (this.WindowState == FormWindowState.Maximized)
                this.WindowState = FormWindowState.Normal;
                this.btnMaximize.Text = "Maximize";
                this.WindowState = FormWindowState.Maximized;
                this.btnMaximize.Text = "Restore";

Open in new window


Author Comment

ID: 36571632
Thanks for the answer I will look at it tonignt.


Author Comment

ID: 36572055

After implementing your code and testing it
I still have the problem.

Your solution did not help?

Peter Kiers

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

617 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