Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7831153
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T11:35:52+00:00 2026-06-02T11:35:52+00:00

I have a UserControl, that contains a panel, the panel contains a picture box.

  • 0

I have a UserControl, that contains a panel, the panel contains a picture box.
When I MouseMove over the Picture Box, I want to update a label on the MainForm.
I have a get/set method on the main form, but how do I use it?? thanks

  public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();
        }
        public String MouseCords
        {
            get { return this.MouseCordsDisplayLabel.Text; }
            set { this.MouseCordsDisplayLabel.Text = value; }
        }
    }


    public partial class ScoreUserControl : UserControl
    {
        public ScoreUserControl()
        {
            InitializeComponent();
        }

        private void ScorePictureBox_MouseMove(object sender, MouseEventArgs e)
        {
            // MainForm.MouseCords("Hello"); //What goes here?
        }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T11:35:59+00:00Added an answer on June 2, 2026 at 11:35 am

    Actually it’s possible to do in your case like:

    ((MainForm)this.ParentForm).MouseCords = "Some Value Here";
    

    But the right way is with events like Felice Pollano mentinoed:

    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();
    
            this.myCustomControlInstanse.PicureBoxMouseMove += new EventHandler<StringEventArgs>(myCustomControlInstanse_PicureBoxMouseMove);
        }
    
        private void myCustomControlInstanse_PicureBoxMouseMove(object sender, StringEventArgs e)
        {
            this.MouseCordsDisplayLabel = e.Value // here is your value
        }
    }
    
    
    public class StringEventArgs : EventArgs
    {
        public string Value { get; set; }
    }
    
    public partial class ScoreUserControl : UserControl
    {
        public event EventHandler<StringEventArgs> PicureBoxMouseMove;
    
        public void OnPicureBoxMouseMove(String value)
        {
            if (this.PicureBoxMouseMove != null)
                this.PicureBoxMouseMove(this, new StringEventArgs { Value = value });
        }
    
        public ScoreUserControl()
        {
            InitializeComponent();
        }
    
        private void ScorePictureBox_MouseMove(object sender, MouseEventArgs e)
        {
            this.OnPicureBoxMouseMove("Some Text Here");
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a user control that contains multiple controls (CheckBox, Button, Label...). I want
I have a page that contains a user control within an update panel. $(document).ready(function()
I have a custom UserControl that contains a grid ...I wish to set the
I have ModalPopupExtender that contains a UserControl that basically consists of a GridView and
I have a Usercontrol(TabUserControl) which contains a TabControl. The Viewmodel of that UserControl loads
I have a UserControl that I want to add at runtime to my current
In a Windows Form application I have a Form with a UserControl that contains
I have a UserControl that contains a TextBox. The TextBox.Text property is data-bound and
I have a usercontrol that is in an asp.net page that contains a button.
I have an update panel which contains a table, to which I add rows

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.