custom dynamic user control with event handler C# WinForm

Sdílet
Vložit
  • čas přidán 25. 07. 2024
  • ☕ Buy me a coffee!
    www.buymeacoffee.com/aaricaaiden
    📧 Email
    aaric.aaiden@gmail.com
    🔗 Source Code :
    www.buymeacoffee.com/aaricaai...
    🔗 Part 2 - With Database :
    • Handling dynamic user ...
    ------------------------------
    Track: Lisbon - Ason ID [Audio Library Release]
    Music provided by Audio Library Plus
    Watch: • Lisbon - Ason ID | Fre...
    Free Download / Stream: alplus.io/lisbon
    ------------------------------
    🎵 Track Info:
    Title: Lisbon
    Artist: Ason ID
    Genre: Dance & Electronic
    Mood: Calm
    ---
    😊 Contact the Artist:
    Ason ID:
    / ason-music
    / asonidoffici. .
    open.spotify.com/artist/5WHsT...
    / artist .
    deezer.com/us/artist/1496561
    / asonid
    / asonsweden
    / asonid
    ---

Komentáře • 67

  • @AaricAaiden
    @AaricAaiden  Před 3 lety +2

    Just found a way to perform a user control click event when click on any control placed on it. Such as button, Labels, & panel etc.
    Load this event on UserControl_Load for every control you want to trigger user control click.
    For example you want user control to be clicked if you click a label:
    YourLabelName.Click += new EventHandler((object sender, EventArgs e) => this.OnClick(e));

  • @younismalik8809
    @younismalik8809 Před 3 lety +2

    Really useful video. Many thanks Aaric!

    • @AaricAaiden
      @AaricAaiden  Před 3 lety

      Glad to hear that. Thanks for watching :)

  • @Neo_Nkosi
    @Neo_Nkosi Před rokem +1

    life saver😆🔥Thank you

  • @exogendesign4582
    @exogendesign4582 Před 3 lety +1

    The one i have been looking for. Thank you so much.

  • @mdsaif3365
    @mdsaif3365 Před 2 lety +1

    Thanks for this such a useful code.
    Keep on.👍🏻

  • @camnguyen3485
    @camnguyen3485 Před 2 lety +1

    thank you very much

  • @stefanypatrick95
    @stefanypatrick95 Před 2 lety +1

    Thanks, gracias aqui un hispanohablante. . .

  • @usmansamad4899
    @usmansamad4899 Před rokem +1

    Thankyou So Much

  • @softfiscalpb674
    @softfiscalpb674 Před rokem +1

    que bom, gostei do seu video. parabens.

  • @user-ur1fk9tr7r
    @user-ur1fk9tr7r Před 2 lety +1

    Can I do like this code if I want to use this user control inside another user control that inside form

  • @user-ur1fk9tr7r
    @user-ur1fk9tr7r Před 2 lety +2

    Thank you for this video it is so great and clear, I want to see how we can link this project with database

    • @AaricAaiden
      @AaricAaiden  Před 2 lety

      Watch this
      czcams.com/video/qa45JdB4ALM/video.html

  • @Platica.Vasile
    @Platica.Vasile Před rokem +1

    thank you so much, dear sir, you made my day !

  • @user-ur1fk9tr7r
    @user-ur1fk9tr7r Před 2 lety +1

    Hello, I want to know how I can create database like what use in this video

  • @md.sobujali3184
    @md.sobujali3184 Před 3 lety +1

    Sir please upload
    electronics instrumentation and measurements 2nd edition david a bell solution

  • @soilobaisa8424
    @soilobaisa8424 Před rokem +1

    hello, I have try this code but there are 3 Error when I start the project It is in
    pb_icon. Image = obj.Icon;
    lbl_title. Text =obj.Title ;
    lbl_subtitle. Text=obj.SubTitle;
    the errors says Cannot implicitly convert type 'System.Windows.Forms.PictureBox' to 'System.Drawing.Image' and Cannot implicitly convert type 'System.Windows.Forms.Label' to 'string'
    please help me fix this

  • @theonlyz100
    @theonlyz100 Před 11 měsíci +1

    There is no event handler of User Control so it does not triger the click even..... This code does not work

  • @user-ur1fk9tr7r
    @user-ur1fk9tr7r Před 2 lety +1

    I do like that code but now it doesn't display the icons , titles and subtitles

  • @robertov2554
    @robertov2554 Před rokem +1

    Hi man, thanks at frist.
    I try this one but when i ry to access to listItems[i] it shows an null reference eception, it seems i cant acces from a UserControl to this Custom UserControl.
    It is only possible to acces to the object with a Form and not wiht other UserControl?

    • @AaricAaiden
      @AaricAaiden  Před rokem

      The list is empty, as indicated by the NullReferenceException, and in this video, we initialise the list with CustomUserControl objects.
      You are most likely missing the following statement:
      listItems[i] = new CustomUserControl();

  • @mrbean27123
    @mrbean27123 Před rokem +1

    How can I add a new item on button click without using SQL Database?

    • @AaricAaiden
      @AaricAaiden  Před rokem

      First, you should go through the link below.
      stackoverflow.com/a/2607043
      and for the images you can keep the paths stored as string along with the data. and when fill values to usercontrols you can get the image using path.
      As below :
      Image.FromFile(imagePathHere)

  • @grandvilletanbunan6435
    @grandvilletanbunan6435 Před 2 lety +1

    hello brother, is it possible to get the value when we click the picturebox, not the usercontrol?

    • @AaricAaiden
      @AaricAaiden  Před 2 lety

      Brother navigate to "Yunis Maruf" conversation. i have already provided solution for this.

    • @grandvilletanbunan6435
      @grandvilletanbunan6435 Před 2 lety

      @@AaricAaiden thank you so much!

  • @GadgetMeta
    @GadgetMeta Před rokem +1

    Using database video please sir

    • @AaricAaiden
      @AaricAaiden  Před rokem

      czcams.com/video/qa45JdB4ALM/video.html

  • @AliHaider-sz5tw
    @AliHaider-sz5tw Před 3 lety +2

    Hi sir i need help about user control how to change label text in dynamically created user control

    • @AaricAaiden
      @AaricAaiden  Před 3 lety

      I have created getter and setter in user control class if you see.

    • @AaricAaiden
      @AaricAaiden  Před 3 lety

      Those getter and setter are used to get and set values to labels placed on a user control.

    • @AaricAaiden
      @AaricAaiden  Před 3 lety

      To set text to label on each dynamic user control. I have created a function (generateDynamicUsercontrol) in this function. You will see the labels text is being initialized.

    • @AaricAaiden
      @AaricAaiden  Před 3 lety

      And to get labels text I have used user control object to access getter and setter of a class inside a dynamically created click event.

    • @AaricAaiden
      @AaricAaiden  Před 3 lety

      Watch video completely you will understand it better. I have also commented every statement in a code.

  • @1222guilherme
    @1222guilherme Před 3 lety +1

    and How i populate labels with SQL database? Please help me

    • @AaricAaiden
      @AaricAaiden  Před 3 lety +1

      Thanks for asking. I will soon upload a tutorial.

    • @AaricAaiden
      @AaricAaiden  Před 3 lety +1

      Video Uploaded !
      czcams.com/video/qa45JdB4ALM/video.html

  • @user-ur1fk9tr7r
    @user-ur1fk9tr7r Před 2 lety +1

    Hi, I have try this code but there are 3 Error when I start the project
    It is in
    pb_icon. Image = value;
    lbl_title. Image =value ;
    lbl_subtitle. Image=value;
    The Errors are because the names 'pb_icon', 'lbl_title' and 'lbl_subtitle' don't exist in the current context
    I just want to know how I can fix it

    • @AaricAaiden
      @AaricAaiden  Před 2 lety +1

      Rename PictureBox to pb_icon in properties tab.
      Label that you are using for title rename to lbl_title
      and lbl_subtitle for sub title label

    • @user-ur1fk9tr7r
      @user-ur1fk9tr7r Před 2 lety +2

      @@AaricAaiden
      I do that and it is works But pictures ,title and subtitle don't display.
      Maybe because I use this user control insaid another user control

    • @robertov2554
      @robertov2554 Před rokem

      Hello!, i have exactly the same problem, it is because we use this UserControl in another UserControl?

  • @roocall9356
    @roocall9356 Před 2 lety +1

    I am having an error it shows Object reference not set to an instance of an object.

  • @DK-yj4tw
    @DK-yj4tw Před 2 lety +1

    What is this message?Corrupt .resource file. unable to read resource from this file Because of invalid Header information. try regenerating the .resource file help Me please

  • @yunismaruf
    @yunismaruf Před 3 lety +1

    I want to add click event to panel , how can do it?

    • @AaricAaiden
      @AaricAaiden  Před 3 lety +1

      If you want that when you click panel. It should perform same as on user control click.
      here is a solution for this:
      YourPanelName.Click +=new EventHandler(( object sender, EventArgs e) => this.OnClick(e));
      Paste this line of code in your user control load event.
      For explanation watch this video
      czcams.com/video/dlYpP6wi7RY/video.html
      from
      3:37 - 3:54

    • @yunismaruf
      @yunismaruf Před 3 lety +1

      @@AaricAaiden thanks for your support,
      I will try it.

    • @AaricAaiden
      @AaricAaiden  Před 3 lety +1

      @@yunismaruf Anytime.

    • @yunismaruf
      @yunismaruf Před 3 lety +1

      @@AaricAaiden THANKS it's worked.

    • @yunismaruf
      @yunismaruf Před 3 lety +1

      @@AaricAaiden thanks it’s worked

  • @umarmoeid2978
    @umarmoeid2978 Před 2 lety +1

    Event Handler doesn't work on user control Controls like click on label it doesn't work

    • @AaricAaiden
      @AaricAaiden  Před 2 lety

      If you want that when you click label. It should perform same as on user control click.
      here is a solution for this:
      YourLabelName. Click +=new
      EventHandler(( object sender, EventArgs e) =>
      this.OnClick(e));
      Paste this line of code in your user control load
      event.
      For explanation watch this video
      czcams.com/video/dlYpP6wi7RY/video.html
      from
      3:37 to 3:54

  • @GrenneAnGel
    @GrenneAnGel Před 3 lety +1

    thanks a lot really helpful, if u just could send me the code

    • @AaricAaiden
      @AaricAaiden  Před 3 lety

      Sure, provide me your email address.

    • @GrenneAnGel
      @GrenneAnGel Před 3 lety

      @@AaricAaiden Also if u could make a video on how to customize datagridview with usercontrol

    • @AaricAaiden
      @AaricAaiden  Před 3 lety +1

      @@GrenneAnGel Sure, Could you provide briefing about what exactly you want to do. So that i can show exact same. instead coding sample.

    • @GrenneAnGel
      @GrenneAnGel Před 3 lety

      @@AaricAaiden i dropped my email address in a reply before. Send me an email and imma send you more details about usercontrol datagridview

    • @AaricAaiden
      @AaricAaiden  Před 3 lety

      @@GrenneAnGel You can check your email.

  • @mrmakinist
    @mrmakinist Před rokem +1

    No dynamic

  • @user-ur1fk9tr7r
    @user-ur1fk9tr7r Před 2 lety +1

    I do like that code but now it doesn't display the icons , titles and subtitles

    • @user-ur1fk9tr7r
      @user-ur1fk9tr7r Před 2 lety

      I use this user control inside another user control
      Is that didn't let the icons, titles and subtitles display