-1

My problem is whenever I double click on an object (e.g picturebox), it enters another window where I can do my coding (which is normal) however, it starts with:

private void pictureBox1_Click(object sender, EventArgs e)

which I don't understand :(

How can I make it into Public Class so I can change the event to "mouse enter" or "mouse leave"?

Thank you in advance.

Visual Vincent
  • 18,045
  • 5
  • 28
  • 75
  • Why did you include C#, VBA and Visual C++ tags? Your title clearly says your question is about Visual Basic. Do **not** just randomly add tags to your post because they sound familiar. Use the ones that **specifically** apply to your question. Tags have meaning and purpose here. VB is **not** VBA, and C++ has absolutely no relation to your question. And `mouse_enter` or `mouse_leave` don't need to be public; they should be private just like click. – Ken White Jul 20 '16 at 02:27
  • The reason your event is `private` is because your object `pictureBox1` is `private`. Why do you want to change an existing event in code behind. Why not create a separate event handler from Designer view? – Mursaleen Ahmad Jul 20 '16 at 02:28
  • @MursaleenAhmad, I'm sorry, but can you tell me how to do just that? I'm a beginner and I'm trying to learn Visual Basic. – Kelvin Jhon Jul 20 '16 at 02:31
  • You can right click the file from Solution Explorer and select designer view. – Mursaleen Ahmad Jul 20 '16 at 02:34
  • @KenWhite, I'm sorry for the taggings. I'm just starting to code and new to this site, so I'm not aware of the differences. [Project](https://postimg.org/image/q680wrjvr/) this is what I'm seeing just to give you an idea. There's no mouse enter or leave event. – Kelvin Jhon Jul 20 '16 at 02:36
  • Is [this](https://stackoverflow.com/questions/1441207/class-name-and-method-name-dropdown-list-is-missing-visual-studio-setting) what you are looking for? – Mark Jul 20 '16 at 03:33
  • You say you're trying to learn Visual Basic, but the code you wrote in the question is C#. Are you sure you are using the correct language? – Visual Vincent Jul 20 '16 at 09:17
  • I changed everything to C# in your question (because that is where your code comes from), you may change it back if you actually start to use Visual Basic. – Visual Vincent Jul 20 '16 at 09:22

2 Answers2

3

If all you want to do is switch from design view to code view then use the F7 key. In older versions of VS, F7 would switch back again too but in later versions you use Shift+F7 to switch from code view to design view.

When in design view, you can select the form or a control/component, open the Properties window, click the Events button and then create or select a handler for any event and/or jump to it in code view. When in code view, you can use the drop-down lists at the top to select the form or a control/component or any field declared WithEvents and to create and/or jump to the handler for that event.

jmcilhinney
  • 50,448
  • 5
  • 26
  • 46
  • [This is](https://postimg.org/image/7iyl47flj/) what I'm trying to achieve, however, [This](https://postimg.org/image/3nv71mwfr/) is what I'm currently getting. The drop down list of event like shown on the first image is not available. I've already removed and reinstalled visual studio community. Please help! – Kelvin Jhon Jul 21 '16 at 02:40
  • @MursaleenAhmad,Sir, [This is](https://postimg.org/image/7iyl47flj/) what I'm trying to achieve, however, [This](https://postimg.org/image/3nv71mwfr/) is what I'm currently getting. The drop down list of event like shown on the first image is not available. I've already removed and reinstalled visual studio community. Please help! – Kelvin Jhon Jul 21 '16 at 02:41
  • @Visual Vincent, Hi sir, sorry for the tags. Would you be able to help me with my problem? I'm trying to get this [dropdown](https://postimg.org/image/7iyl47flj/) list of event when I enter the code view. However, [This](https://postimg.org/image/3nv71mwfr/) is what I'm currently getting. The drop down list of event like shown on the first image is not available. I've already removed and reinstalled visual studio community. Please help! – Kelvin Jhon Jul 21 '16 at 02:43
0

Already resolved. I was able to do it by creating another project and choosing the windows form application as visual basic, not c#.

  • In C#, you use the Properties window in the designer as I described in my answer. If you want to add an event handler in code you simply start typing and Intellisense will help you. There's no equivalent to the VB code editor functionality because there's no equivalent to the `WithEvents` and `Handles` keywords. – jmcilhinney Jul 21 '16 at 04:15