473,473 Members | 1,759 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Class inherits form?

I have a class that inherits a form. How can I handle clicks and changes to
controls on the inherited form within my class?

Cheers,
Tull.
Nov 21 '05 #1
4 1372
July 25, 2005

LOL It has been a long time since I inherited anything (and it was
nice!), but I believe you must go to the form that you are inheriting from
and mark the controls that you want to handle with the Protected modifier.
This way inherited forms can control them, compared to the Private modifier
which only allows the same class. Hope this helps! :-)

--
Joseph Bittman
Microsoft Certified Application Developer

Web Site: http://71.39.42.23
Static IP


"Tull Clancey" <tu**********@btopenworld.com> wrote in message
news:dc**********@nwrdmz03.dmz.ncs.ea.ibs-infra.bt.com...
I have a class that inherits a form. How can I handle clicks and changes
to controls on the inherited form within my class?

Cheers,
Tull.

Nov 21 '05 #2
Thanks for the feedback. I'm not sure I have explained things correctly.

I'm trying to setup a simple input box. I know this would be far better off
as a control, but it seems a simple way to learn the inheritance thingy to
start with. When complete it wouldn't take much to convert it anyway.

I want a class, clsInput. This class will have several properties,
UpperCase, NumericOnly, TextOnly, Password, Prompt, etc. And probably a
single function GetInput to return the text entered.

I want the class to load a form and set the input parameters, then accept an
input and return the text entered, ie.

Dim str As String
Dim inp As New clsInput
inp.TextOnly = True
inp.Prompt = "Give me some text!"
str = inp.GetInput

I've managed to half the code between a class and a form, but this seems a
little daft, why have a class and a form if you can do exactly the same with
a form and a couple of public variables.

I would like the class to be able to create the form and the form controls,
(which I can do easily) and have the class control the form while displayed.
The only other problem is, as the form has to be 'ShowDialog' how do I
control clicks and key presses from the class when the form has Modal
control?

Cheers,
Tull.
"Joseph Bittman MCAD" <Ry*********@msn.com> wrote in message
news:e$**************@TK2MSFTNGP12.phx.gbl...
July 25, 2005

LOL It has been a long time since I inherited anything (and it was
nice!), but I believe you must go to the form that you are inheriting from
and mark the controls that you want to handle with the Protected modifier.
This way inherited forms can control them, compared to the Private
modifier which only allows the same class. Hope this helps! :-)

--
Joseph Bittman
Microsoft Certified Application Developer

Web Site: http://71.39.42.23
Static IP


"Tull Clancey" <tu**********@btopenworld.com> wrote in message
news:dc**********@nwrdmz03.dmz.ncs.ea.ibs-infra.bt.com...
I have a class that inherits a form. How can I handle clicks and changes
to controls on the inherited form within my class?

Cheers,
Tull.


Nov 21 '05 #3
July 25, 2005

Why does the form have to be displayed with showdialog? Why can't it be
..Show? Anyway, if it is Show and not showdialog, then you could always
create an event and handler in the form that wants to control the other
events. Then from the class that opened the form, when the user clicks a
control, raise the event that you created in the .Show form so then it can
handle them. I wouldn't be sure how to do this if it must be called by
Showdialog. I hope this helps! :-)

--
Joseph Bittman
Microsoft Certified Application Developer

Web Site: http://71.39.42.23
Static IP


"Tull Clancey" <tu**********@btopenworld.com> wrote in message
news:dc**********@nwrdmz01.dmz.ncs.ea.ibs-infra.bt.com...
Thanks for the feedback. I'm not sure I have explained things correctly.

I'm trying to setup a simple input box. I know this would be far better
off as a control, but it seems a simple way to learn the inheritance
thingy to start with. When complete it wouldn't take much to convert it
anyway.

I want a class, clsInput. This class will have several properties,
UpperCase, NumericOnly, TextOnly, Password, Prompt, etc. And probably a
single function GetInput to return the text entered.

I want the class to load a form and set the input parameters, then accept
an input and return the text entered, ie.

Dim str As String
Dim inp As New clsInput
inp.TextOnly = True
inp.Prompt = "Give me some text!"
str = inp.GetInput

I've managed to half the code between a class and a form, but this seems a
little daft, why have a class and a form if you can do exactly the same
with a form and a couple of public variables.

I would like the class to be able to create the form and the form
controls, (which I can do easily) and have the class control the form
while displayed. The only other problem is, as the form has to be
'ShowDialog' how do I control clicks and key presses from the class when
the form has Modal control?

Cheers,
Tull.
"Joseph Bittman MCAD" <Ry*********@msn.com> wrote in message
news:e$**************@TK2MSFTNGP12.phx.gbl...
July 25, 2005

LOL It has been a long time since I inherited anything (and it was
nice!), but I believe you must go to the form that you are inheriting
from and mark the controls that you want to handle with the Protected
modifier. This way inherited forms can control them, compared to the
Private modifier which only allows the same class. Hope this helps! :-)

--
Joseph Bittman
Microsoft Certified Application Developer

Web Site: http://71.39.42.23
Static IP


"Tull Clancey" <tu**********@btopenworld.com> wrote in message
news:dc**********@nwrdmz03.dmz.ncs.ea.ibs-infra.bt.com...
I have a class that inherits a form. How can I handle clicks and changes
to controls on the inherited form within my class?

Cheers,
Tull.



Nov 21 '05 #4
When you declare public objects (the controls), you're going to want to
declare them with WithEvents. Then it should work just like on a normal
form.

Public WithEvents yourcontrol As New Button (for example)

Tull Clancey wrote:
I have a class that inherits a form. How can I handle clicks and changes to
controls on the inherited form within my class?

Cheers,
Tull.

Nov 21 '05 #5

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

Similar topics

4
by: Mike | last post by:
Please help this is driving me nuts. I have 2 forms, 1 user class and I am trying to implement a singleton class. Form 1 should create a user object and populate some properties in user. Form2...
5
by: ozie | last post by:
Hi , I am new to ASP.NET. I was reading about Page class in one of the ASP.NET books and am confused with the way the Page class is actually implemented.What is didnt understand in when is this...
0
by: ElanKathir | last post by:
Hi All ! Here by attached two type's of Code, One -> ASP Controls Tag Code Another -> Server side Script of the page. The Server Side Script have Two Class
13
by: Duron | last post by:
I created a new folder using VS.NET 2003. Then I created a new web form under that folder, say, \Member\Default.aspx. However, even if I didn't do anything to that page, a run-time error appears...
9
by: Richard Brown | last post by:
Can anyone give me a good argument one way or another? I have an 'address' set of fields that are used in various situations (a client has an address, a destination has an address, etc). These...
5
by: RSH | last post by:
I havent been able to set a property from another class with out getting some sort of error. Can someone please tell me what I'm doing wrong here? Public Class Form1
7
by: Paul | last post by:
Hello, I'm coming from a PHP background and am working on a large-scale VB.NET project. One of the cornerstones of this project is a reusable form class, to standardize our web forms. My goal...
5
by: Rob | last post by:
In many articles related to VB.net the word "class" is used... How many meanings are there to this word ? "possible to derived a class from another" "forms are full-fledged classes" "base...
5
by: AWesner | last post by:
I've been working on a project to help myself better understand how inherited classes work. I think I've learned more about classes by doing this than any other effort I've made. I've tried to...
1
by: steven scaife | last post by:
Hi I have created a class that inherits from dictionarybase code below. Public Class FrmLabels Inherits Label Private m_Lbl As Label Public Property lbl() As Label Get Return m_Lbl End Get
0
Oralloy
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
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...
0
agi2029
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,...
0
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.