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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T05:26:30+00:00 2026-05-15T05:26:30+00:00

I have a User Control for typical CRUD like actions on my WinForm app.

  • 0

I have a User Control for typical CRUD like actions on my WinForm app.
Validate, Insert, Update, Clear, Cancel, and Delete.

On every form I put this on I end up adding the click event, ucPersonNav.btnValidate.Click += new EventHandler(btnValidate_Click);, for every button.

What I am wondering is can I have the Events be on the User Control themselves and just have them point to a Method that I override on a Form by Form basis?

Something like this –>

namespace psUserControls
{

 using System;

using DevExpress.XtraEditors;

public partial class ucVIUCCDwithWhoDoneIt : XtraUserControl
{
    public ucVIUCCDwithWhoDoneIt()
    {
        InitializeComponent();
    }

    private void btnValidate_Click(object sender, EventArgs e)
    {
        ValidateEvent();
    }
}

}

And then on a Form have this –>

void ValidateEvent()
{
    if (dxValidDiagnosis.Validate())
    {
        if (planDiagnosisID != 0)
        {
            ucNavDiagnosis.btnUpdate.Enabled = true;
            ucNavDiagnosis.btnDelete.Enabled = true;
        }
        ucNavDiagnosis.btnInsert.Enabled = true;
    }
}

Is this feasible? Is it idiotic? If Yes then No then what steps do I need to take to make this work?

Thanks

  • 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-15T05:26:31+00:00Added an answer on May 15, 2026 at 5:26 am

    i think .. not a bad idea..
    but the approach would be very specific to your application.

    we can have an enum for CRUD buttons – 6 enum items as you specified.

    We can have a single event handler – delegate which takes above enum as a parameter.
    Write an event (MyButtonClickedEvent) for this delegate which will be fired on each button clicked event.

    on your control, on each button clicked event you can fire this event with respective enum item as a parameter.
    e.g. on Validate button click, fire MyButtonClickedEvent with parameter as validate enum item.
    On Inser button click, fire same MyButtonClickedEvent with parameter as Insert enum item.

    This way you will have to handle single event on your form. You will be firing different events from your control. But this is to be done only once. On your form you will write a just one single handler – Method. In this method, you can differentiate depending on the enum type. .Net supports enum in switch-case construct. So you can easily identify the opteration that you have to perform.

    All the users of your control will find it easier as they have to handle just one event. They will ignore the cases in switch construct which they are not interested.

    Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have user control in my MVC2 app placed in the Content folder (it's
I have an User Control that host another controls like panel, chart controls. Right
I have a user control with a div like this: <div runat=server id=pnlShippingMethods class=checkoutstep>
I have a user control with several buttons, which need to take different actions
I have user control which looks like <div> <asp:LinkButton ID=btnShow runat=server Text=Select CausesValidation=false />
i have user control, which i render on several views. i want to show
I have a user control bound to appropriate ViewModel. I have a GraphLayout (using
I have this User Control XAML: <Window x:Class=MyProj.Dialog xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml xmlns:mc=http://schemas.openxmlformats.org/markup-compatibility/2006 xmlns:d=http://schemas.microsoft.com/expression/blend/2008 xmlns:shell=http://schemas.microsoft.com/winfx/2006/xaml/presentation/shell mc:Ignorable=d>
I have a user control that is being integrated to the page on run
I have a user control called DashboardUserControl.ascx It has a function: public void setPagination(Boolean

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.