Hello,
I'm trying to make an event that will close a usercontrol and open another one. The first user control is for login and when the password have been validated, the event should fire and the event/form would close the usercontrol. The problem is that the form can't see the event with the error "are you missing a using directive or an assembly reference?"
The form code: - using System;
-
using System.Collections.Generic;
-
using System.ComponentModel;
-
using System.Data;
-
using System.Drawing;
-
using System.Linq;
-
using System.Text;
-
using System.Windows.Forms;
-
using System.Data.Odbc;
-
-
namespace økonomi
-
{
-
-
public partial class MainForm : Form
-
{
-
UserControl LoginControl = new LoginControl();
-
public MainForm()
-
{
-
InitializeComponent();
-
InitControl();
-
}
-
-
void InitControl()
-
{
-
-
LoginControl.OnMyEvent += new LoginControl.onMyEventHandler(catchevent);
-
panel1.Controls.Add(LoginControl);
-
}
-
-
static void catchevent(object sender, EventArgs e)
-
{
-
MessageBox.Show("Hello");
-
}
-
}
-
}
It's line 26 that gives me the error (OnMyEvent).
And the usercontrol: - using System;
-
using System.Collections.Generic;
-
using System.ComponentModel;
-
using System.Drawing;
-
using System.Data;
-
using System.Linq;
-
using System.Text;
-
using System.Windows.Forms;
-
-
namespace økonomi
-
{
-
-
public partial class LoginControl : UserControl
-
{
-
public delegate void onMyEventHandler(object sender, EventArgs e);
-
public event onMyEventHandler OnMyEvent;
-
-
public LoginControl()
-
{
-
InitializeComponent();
-
}
-
-
public void btnLogin_Click(object sender, EventArgs e)
-
{
-
if (txtPwd.ToString() == "1234")
-
{
-
OnMyEvent(this, e);
-
}
-
-
}
-
}
-
}
5 2082
The cause for this error are:
1.You do not have class with that name in your project
2. You add the class later on and run the project without compiling
3. You have the class but you do not specify the namespace via Imports or using keyword
Even though you have the dll added to your reference, use Imports statement.
For example if we have a tiered app, in which there is a namespace called BusinessDataObj ects, in which I write all my classes, to reference this in my project I add the dll to this namespace, but then in my code in the presentation layer to use this I also write using BusinessDataObj ects. in your case it will be Imports EmailMessage.
Hope this works
I'm not sure i understand what dll am i suppose to import where? I think it's you point 3 that is the problem in my case...
Why namespace EmailMessage? ("in your case it will be Imports EmailMessage.") This namespace isn't used here?
Do you have multiple projects or are LoginControl and MainForm in the same project/assembly?
Yes they are in the same project.
Oh, I think, I figured out, what's wrong:
Change line 16 from
UserControl LoginControl = new LoginControl();
to LoginControl LoginControl = new LoginControl();
[/code]
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Jason |
last post by:
I have a main form with a sub form. All the fields in the subform
are mandatory. I had some code on the main form Before Update Event to
check if all the fields in the sub form have data. If not, I want to
cancel update event and allow user to enter the sub form to fill in all
mandatory fields. I tried many code and don't have any solution to work
around. It never allows me to go into the sub form again after triggering
the before update...
|
by: athlonman |
last post by:
Hi all!!
II'm trying to set the Text of a TextBox in "Form1" when I click a
Button in a UserControl. My code is:
:
public class Form1 : System.Windows.Forms.Form
{
public System.Windows.Forms.TextBox textBox1;
private WindowsApplication1.UserControl1 userControl11;
|
by: ATS |
last post by:
PRB: Can not get UserControl/HTML/OBJECT to work on XP/SP2/IIS/IE6
Please help,
I can not get my UserControl to work from a simple OBJECT tag in a simple
HTML web page on Windows XP with SP2 and IIS. I have made UserControls
before, but for whatever reason, XP/SP2/IIS/something is not letting the web
page run the UserControl, giving an error of "Object doesn't support this
property or method". Here are the steps to reproduce:
|
by: feng |
last post by:
We have a windows form project that has multiple child
forms inherit from one base form. In our base form's form
load event handler, we have some common logic in there.
These common logic is needed by all the child forms when
they load up. So when a child form gets called, the base's
form load event handler gets called first, so is the
common logic, then the child's load event handler gets
executed.
So far, everything works fine,...
|
by: gsb58 |
last post by:
Hi!
In my application I have code that will give the user a choice when he
click's the close button on the ToolBar1.
However, when he clicks the close button of the form, the form will
shut down even if he chooses the cancel button of the messagebox that
pop's up.
Now...if he, on the other hand, chooses ALT+F4, then I catch this in
| |
by: kmercer46 |
last post by:
i want to use a form's OnError event to close the form if an error
occurs, but the event is not working. it just brings up the error
window with the End and Debug buttons. i remember seeing an option
somewhere that consults the form's event before any other control's
event, but i can't find that in any property windows. is that the
issue?
or.. maybe someone can hear my main problem and address another way to
handle it:
|
by: lesperancer |
last post by:
I've got application A, with a hidden form, whose unload event is
cancelled unless you use an 'exit' button (so I can do special
processing)
this works fine when using just application A and it prevents me from
'x'ing out of msaccess.exe
now, I open application A from within application B using the code
below
|
by: PW |
last post by:
Hi,
This is bizarre. I've check and rechecked the spelling, cut and paste
the name of the form (when trying to rename the form) and the control
yet I still get a parameter prompt when the form runs. I've even
deleted the control and started over.
This is the code for the recordsource of the form:
"SELECT * FROM qryGuestStorePurchases_pw WHERE
|
by: =?Utf-8?B?YzY3NjIyOA==?= |
last post by:
Hi all,
I guess this probably a very silly question. I am not sure if this can be
done in classical asp. A button has to be clicked if a selection in drop
down list has been changed. If not, a pop up message pops and reminds the
user you need to click the button before continue. Can this be done in some
ways???
Thank you!
--
Betty
|
by: Hillbilly |
last post by:
Right now I have a lot of form data in an event handler I will need to
reuse in other event handlers in the same page. Using firstName1 and
firstName2 for strings can't possibly be the way I should be coding this
type of task not to mention its tedious as all get out. What's a workable
way to move the initialization out of the event handler and into the class
or wherever so the data in the form can be used by different event handlers
in...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |