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 6574047
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:12:39+00:00 2026-05-25T15:12:39+00:00

i created user control which looks like this: and code behind looks like: using

  • 0

i created user control which looks like this:

enter image description here

and code behind looks like:

using System;
using System.Windows.Forms;

namespace Controlls
{
    public partial class Toolbar : UserControl
    {
        public Toolbar()
        {
            InitializeComponent();
        }

        private void pbNaprej_Click(object sender, EventArgs e)
        {

        }

        private void pbNazaj_Click(object sender, EventArgs e)
        {

        }

        private void pbNovo_Click(object sender, EventArgs e)
        {

        }

        private void bpbBrisi_Click(object sender, EventArgs e)
        {

        }

        private void pbPotrdi_Click(object sender, EventArgs e)
        {

        }

        private void txtOd_TextChanged(object sender, EventArgs e)
        {

        }
    }
}

now i move this UC to form but there is a problem. How to get this events from UC. I need to implement click events for buttons in form where i use this user control. What i can see is that i can use it like one component and i can not get separate buttons from it.

  • 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-05-25T15:12:39+00:00Added an answer on May 25, 2026 at 3:12 pm

    Add 2 event handlers for yor control, and subscribe to the toobox event at the place you use it:

    using System; 
    using System.Windows.Forms; 
    
    namespace Controlls 
    { 
        public enum ToolboxButtonType { Potrdi, Brisi, Novo, Nazaj, Naprej } 
        public partial class Toolbar : UserControl 
        { 
            public Toolbar() 
            { 
                InitializeComponent(); 
            } 
    
            private void pbNaprej_Click(object sender, EventArgs e) 
            { 
                OnToolboxClick(ToolboxButtonType.Naprej);
            } 
    
            private void pbNazaj_Click(object sender, EventArgs e) 
            { 
                OnToolboxClick(ToolboxButtonType.Nazaj);
            } 
    
            private void pbNovo_Click(object sender, EventArgs e) 
            { 
                OnToolboxClick(ToolboxButtonType.Novo);
            } 
    
            private void bpbBrisi_Click(object sender, EventArgs e) 
            { 
                OnToolboxClick(ToolboxButtonType.Brisi);
            } 
    
            private void pbPotrdi_Click(object sender, EventArgs e) 
            { 
                 OnToolboxClick(ToolboxButtonType.Potrdi);
            } 
    
            private void txtOd_TextChanged(object sender, EventArgs e) 
            { 
                 OnTextChanged(txtOd.Text);
            } 
        }
        private OnToolboxClick(ToolboxButtonType button)
        {
            if (ToolboxClick != null)
            {
                ToolboxClick(this, new ToolboxClickEventArgs(button));
            }
        }
        private OnTextChanged(string text)
        {
            if (ToolboxTextChanged!= null)
            {
                ToolboxTextChanged(this, new ToolboxTextChangedEventArgs(text));
            }
        }
        public class ToolboxTextChangedEventArgs: EventArgs
        {
            public string Text { get; private set; }
            public ToolboxClickEventArgs(string text) { Text = text; }
        }
        public class ToolboxClickEventArgs : EventArgs
        {
            public ToolboxButtonType Button { get; private set; }
            public ToolboxClickEventArgs(ToolboxButtonType button) { Button = button; }
        }
        public event EventHandler<ToolboxClickEventArgs> ToolboxClick;
        public event EventHandler<ToolboxTextChangedEventArgs> ToolboxTextChanged;
    } 
    

    For example:

    //Toolbar toolbar = new Toolbar();
    toolbar.ToolboxTextChanged += (s, e) => { btn1.Text = e.Text; };
    toolbar.ToolboxClick += (s, e) => 
    {
        swith(e.Button)
        {
            case ToolboxButtonType.Brisi: //
                break;
            default:
                break;
        }
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I created a DatePicker user control (ASP code below, no code behind) which is
I've created a simple user control which is manually created with something like MyUserControl
I have usercontrols which inherit a base class which looks like this: BasePage.cs: using
I have created a UserControl using a DevExpress XtraTreeList. Basically in this user control
I am using MVVM Light. I have created a window that looks like this:
I have created a user control (CheckedDirTree) that exposes a CheckedFolder property which in
I've created a custom user control that has several properties. One specifies which database
I'm trying to create User Control which will work like a rich button. It's
I created a UserControl in WPF. This user control has several text boxes that
What gives? My previously created user control is visible, but the newly created one

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.