locked
Which event it should be RRS feed

  • Question

  • Hi,
    On VS 2008 project, within one form, I see these codes
            Me.CmdSave.BackColor = System.Drawing.Color.White
            Me.CmdSave.Font = New System.Drawing.Font("Tahoma", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
            Me.CmdSave.Image = CType(resources.GetObject("CmdSave.Image"), System.Drawing.Image)
            Me.CmdSave.Location = New System.Drawing.Point(858, 494)
            Me.CmdSave.Name = "CmdSave"
            Me.CmdSave.Size = New System.Drawing.Size(97, 45)
            Me.CmdSave.TabIndex = 43
            Me.CmdSave.Text = "OK"
            Me.CmdSave.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText
            Me.CmdSave.UseVisualStyleBackColor = False
            ...
            Me.Controls.Add(Me.CmdSave)
            ...


    but I really cannot find out which button is being fired, to the above button. Any ideas?

    Many Thanks & Best Regards, Hua Min

    Friday, March 6, 2015 6:15 AM

Answers

  • but I really cannot find out which button is being fired, to the above button.

    Do you mean "which event handler code is being executed for the above button click"?  If that code has been added into the form class, then there is none.  To make the code complete there will have to be an AddHandler statement somewhere that associates an event of that control (such as the click event) with a method.  If it's in the lines you have deleted it will be

        AddHandler Me.CmdSave.Click, AddressOf <some method>

    If that code is automatically created by the designer then the event won't exist until you create it.  Double click the control in the designer and a template for a handler for the default control event will be created.

    • Marked as answer by Youjun Tang Tuesday, March 17, 2015 1:57 AM
    Friday, March 6, 2015 6:27 AM

All replies

  • The button click even for a button named CmdSave if in fact CmdSave is a button.

    Since that is all the code you display how could anybody else see the code which that control uses in order to attempt to determine which event it is using?

    Or perhaps you want to know what event that code is used in which would be the Form Load event probably.


    La vida loca



    Friday, March 6, 2015 6:21 AM
  • but I really cannot find out which button is being fired, to the above button.

    Do you mean "which event handler code is being executed for the above button click"?  If that code has been added into the form class, then there is none.  To make the code complete there will have to be an AddHandler statement somewhere that associates an event of that control (such as the click event) with a method.  If it's in the lines you have deleted it will be

        AddHandler Me.CmdSave.Click, AddressOf <some method>

    If that code is automatically created by the designer then the event won't exist until you create it.  Double click the control in the designer and a template for a handler for the default control event will be created.

    • Marked as answer by Youjun Tang Tuesday, March 17, 2015 1:57 AM
    Friday, March 6, 2015 6:27 AM
  • Hello,

    You should be indicating exactly which file this is located in i.e. Form1.vb or Form1.Designer.vb. Since you did not write this then it must be generated code used to display a control or controls on the form's canvas.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem.

    Friday, March 6, 2015 12:04 PM
  • None,

    Click in the designer on the button CmdSave and a Sub with an event handler connected to it will be created in the code part.


    Success
    Cor

    Friday, March 6, 2015 12:12 PM