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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T05:46:56+00:00 2026-05-18T05:46:56+00:00

I am creating buttons on the fly and creating event handlers for them. When

  • 0

I am creating buttons on the fly and creating event handlers for them. When the code runs everything works fine as far as populating the menu on the fly successfully. When I click a button the event fires, but sender=Nothing and the Object is not set to instance exception comes up. Any Ideas? Must be missing something.

Imports DevExpress.XtraBars.Ribbon

Public Class Form1

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim menu As New RibbonControl
        Dim aPage As New RibbonPage("Nicks Page")
        'groups'
        Dim aGroup1 As New RibbonPageGroup("1st Group")

        'ADD BUTTONS TO RIBBON GROUP HERE'
        Dim i As New DevExpress.XtraBars.BarButtonItem()
        i.Caption = "Nicks Button"
        AddHandler i.ItemClick, AddressOf y
        aGroup1.ItemLinks.Add(i)

        Dim i2 As New DevExpress.XtraBars.BarButtonItem()
        i2.Caption = "Nicks Other Button"
        AddHandler i2.ItemClick, AddressOf y
        aGroup1.ItemLinks.Add(i2)

        aPage.Groups.Add(aGroup1)
        menu.Pages.Add(aPage)
        Me.Controls.Add(menu)
    End Sub

    Private Sub y(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs)
        'EXCEPTION SENDER=NOTHING MSGBOX FAILS'
        MsgBox(CType(sender, DevExpress.XtraBars.BarButtonItem).Caption)
    End Sub
End Class
  • 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-18T05:46:57+00:00Added an answer on May 18, 2026 at 5:46 am

    The sender is the BarManager. Use e.Item instead.

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

Sidebar

Related Questions

I'm creating buttons dynamically on an Excel userform with the following code: With Me.CurrentFrame.Controls.Add(Forms.CommandButton.1)
I am creating some buttons dynamically and assigning them IDs. When ever someone clicks
Programmatically I am creating buttons and keeping some background image using setBackgroundImage. I want
I am programatically creating buttons and each button has a tag binary array. While
hi i am new to iPhone.what i did is creating a 4 buttons individually.i
hi i am new to iphone. what i did is creating group of buttons
I'm creating a simple blackberry application for testing purposes and my custom buttons do
I'm creating ipad application. It has just 2 views. One view has few buttons.
When loading a page for the first time (!IsPostback), I am creating a button
I am creating a Control Template for the Button control in Silverlight 2. I

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.