473,385 Members | 1,400 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Passing System.EventArgs as parameters

Hi everyone,

I've been using VB.NET for about 6 weeks now and I keep stumbling on a
concept that I hope someone can clear up for me. Each event of a
control has 2 parameters, sender and e....I am not understanding what
the purpose of those parameters are. Can someone clear that up?

Along those lines, I also don't understand how to make a call to a
Click event...what are you supposed to pass in?

In a program that I am working on I need to draw a border around a
panel. I did some research and found some code that will do just that
(sorry if it pastes ugly):

Private Sub PaintBorder(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs)
ControlPaint.DrawBorder(e.Graphics, e.ClipRectangle,
Color.Black, 3, ButtonBorderStyle.Solid, Color.Black, 3,
ButtonBorderStyle.Solid, Color.Black, 3, ButtonBorderStyle.Solid,
Color.Black, 3, ButtonBorderStyle.Solid)
End Sub

How would I call this function if I wanted to paint a border on a panel
called Panel1???

Thank you in advance for any help!

Nov 21 '05 #1
2 9815
The S is the source object (Form, control, class, etc.) that fired the event.
If you want to fire the click event for a control, use
myControl.PerformClick.

In the Click event, you can access the source object's properties, methods,
etc. by:

DirectCast ( S, myControlThatFiredEventType).myControlThatFiredEve ntProperty1.

For example if a Button click event is fired from a form, you can set the
form''s backcolor in the click event as follows:

DirectCast(S, Form).BAckColor = Color.Red

Hope this helps.

--
Dennis in Houston
"GatorBait" wrote:
Hi everyone,

I've been using VB.NET for about 6 weeks now and I keep stumbling on a
concept that I hope someone can clear up for me. Each event of a
control has 2 parameters, sender and e....I am not understanding what
the purpose of those parameters are. Can someone clear that up?

Along those lines, I also don't understand how to make a call to a
Click event...what are you supposed to pass in?

In a program that I am working on I need to draw a border around a
panel. I did some research and found some code that will do just that
(sorry if it pastes ugly):

Private Sub PaintBorder(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs)
ControlPaint.DrawBorder(e.Graphics, e.ClipRectangle,
Color.Black, 3, ButtonBorderStyle.Solid, Color.Black, 3,
ButtonBorderStyle.Solid, Color.Black, 3, ButtonBorderStyle.Solid,
Color.Black, 3, ButtonBorderStyle.Solid)
End Sub

How would I call this function if I wanted to paint a border on a panel
called Panel1???

Thank you in advance for any help!

Nov 21 '05 #2
One more answer to your last question:

Try Panel1.Invalidate..this will trigger the Paint Event.
--
Dennis in Houston
"GatorBait" wrote:
Hi everyone,

I've been using VB.NET for about 6 weeks now and I keep stumbling on a
concept that I hope someone can clear up for me. Each event of a
control has 2 parameters, sender and e....I am not understanding what
the purpose of those parameters are. Can someone clear that up?

Along those lines, I also don't understand how to make a call to a
Click event...what are you supposed to pass in?

In a program that I am working on I need to draw a border around a
panel. I did some research and found some code that will do just that
(sorry if it pastes ugly):

Private Sub PaintBorder(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs)
ControlPaint.DrawBorder(e.Graphics, e.ClipRectangle,
Color.Black, 3, ButtonBorderStyle.Solid, Color.Black, 3,
ButtonBorderStyle.Solid, Color.Black, 3, ButtonBorderStyle.Solid,
Color.Black, 3, ButtonBorderStyle.Solid)
End Sub

How would I call this function if I wanted to paint a border on a panel
called Panel1???

Thank you in advance for any help!

Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Johnny | last post by:
I'm a rookie at C# and OO so please don't laugh! I have a form (fclsTaxCalculator) that contains a text box (tboxZipCode) containing a zip code. The user can enter a zip code in the text box and...
8
by: Johnny | last post by:
I'm a rookie at C# and OO so please don't laugh! I have a form (fclsTaxCalculator) that contains a text box (tboxZipCode) containing a zip code. The user can enter a zip code in the text box and...
7
by: Anne | last post by:
hie there, i want to be able to pass multiple parameters to another page. currently, i am able to do so, but somehow i feel it is not the correct way to do it. below is part of what i have so far....
0
by: Paul Allan | last post by:
I am new to ASP.net (intermediate ASP developer). I am developing a ASP.net web application and I am having some difficulty calling and passing parameters to a function that is declared in my...
5
by: Jim via DotNetMonster.com | last post by:
Hi, I need to pass the value of a variable from one function to another but I don't seem to get the value. I declare the variable outside all functions. What I'm trying to do is that when the...
0
by: NicK chlam via DotNetMonster.com | last post by:
this is the error i get System.Data.OleDb.OleDbException: Syntax error in INSERT INTO statement. at System.Data.Common.DbDataAdapter.Update(DataRow dataRows, DataTableMapping tableMapping) at...
7
by: Richard Grant | last post by:
Hi. In c/C++ i can pass the address of a subroutine to another subroutine as an actual parameter How do I do that in VB .NET What should be the syntax for a parameter to receive the address of a...
8
by: Robert | last post by:
I am creating a small help browser. It is pretty much finished except I cannot find how to pass a file to it (i.e. browser.exe index.html, or any html file, and the html file opens in the browser)...
4
by: jcrouse | last post by:
I have an app with form1 and form2. Form1 has a label control. Form2 has a checkbox and OK button. By default the label on form1 is hidden. When I lauch my app form1 is the default. I right click on...
4
by: jtammyg | last post by:
Hi! I have the following snippet that gives the name of the sql servers installed: Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.