[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Raiseevent in a form in usercontrol

Posted on 2006-07-10
6
Medium Priority
?
284 Views
Last Modified: 2013-12-25
hey there.

I have a MDI form wi th toolbar. then, forms (MDI childs) that load usercontrols. few of those usercontrols may have internal forms. I want the toolbar buttons to relate to events occur in the usercontrols' forms. so where is the problem?

I declared public event in the usercontrol. but since the event itself occur in one of the usercontrol's form,  I can't raise the event.  as far as i know, I don't have access from forms to the usercontrol's variables and such. how do I that?
0
Comment
Question by:avi666
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17071900
you have to catch, in the usercontrol, a internal event of the form, from where you then can raise the usercontrol's event.
or, give the usercontrol a FRIEND sub that can raise the event, and pass the usercontrol object reference to the form so it can call that sub
If you need furhter explanations, don't hesitate to ask
0
 

Author Comment

by:avi666
ID: 17072961
hey angelIII. 10x  very much for your suggestion.
I won't hesitate to ask further explanation :)

I have a save button in the MDI toolbar and want to save changes made in the internal form of the usercontrol.

so in the MDI form i have the code:

sub toolbar_click(...)
     MDIchild.mycontrol.LogSave
end sub

in the usercontrol I have:
Public Sub LogSave()
     Call frm.SaveForm
Exit Sub

and in the frm:
Public Sub SaveForm()
...
end sub

so far, so good. the prob is that the save button is initially disabled and i want to enable it whenever a txt_change event occur in the usercontrol's form. so i added:
 
private sub mycontrol_SaveEvent
   MDImain.toolbar(SaveButton).enabled=true
end sub

and in the usercontrol declaration section:

public event SaveLog

and now I need to complete the circle with the raiseevent somewhere in some of the form's txt_change events.
how I do that with friend sub?

10x in advance.
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 250 total points
ID: 17074502
--- internal form code ---

private ocxToolbar as control

Public Sub InitToolbar ( c as control )
  set ocxToolbar = c
End Sub

Private Sub Withevents txt_change( ... )
  c.RaiseMyEvent ( ... )
End Sub

--- toolbar control ---

public event SaveLog

private gfrmInternalform as frmInternalform

Private Sub Class_Initialize ()
  set gfrmInternalForm = new frmInternalform
  gfrmInternalForm.initToolbar me
end sub

Friend Sub RaiseMyEvent (...)
  Raisevent SaveLog
End Sub

This should do it...
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:avi666
ID: 17079173
few questions.

what is "--- toolbar control ---"? where should I place the code beneth it?
in the usercontrol?

what do I do with ocxToolbar after assigning it with c?
do I need to add class module for it? (Class_Initialize )
if so, who's "Me" in that sub?

also, what is Private Sub Withevents? the compiler bugs me with this declaration...

I'm  a bit clueless...
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17079205
>--- toolbar control ---
should actually read

--- your usercontrol ---


withevents was too much there:
Private Sub txt_change( ... )
  c.RaiseMyEvent ( ... )
End Sub

>gfrmInternalForm.initToolbar me
the ME refers to the usercontrol itself
0
 

Author Comment

by:avi666
ID: 17145355
well, I guess those ideas were good in their ways. I decided to stop messing with it and save the internal form directly from the form.

how easy is that? :)

take the points as a thank for your efforts.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question