473,791 Members | 3,251 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

form objects into class objects

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
Set(ByVal Value As Label)
m_Lbl = Value
End Set
End Property

Sub New(ByVal lbl As Label)
Me.m_Lbl = m_Lbl
End Sub

End Class

Public Class FrmDDL
Inherits DropDownList
Private m_DDL As DropDownList

Public Property DDL() As DropDownList
Get
Return m_DDL
End Get
Set(ByVal Value As DropDownList)
m_DDL = Value
End Set
End Property

Sub New(ByVal DDL As DropDownList)
Me.m_DDL = m_DDL
End Sub

End Class

Public Class FrmTxt
Inherits HtmlInputText
Private m_DDL As HtmlInputText

Public Property DDL() As HtmlInputText
Get
Return m_DDL
End Get
Set(ByVal Value As HtmlInputText)
m_DDL = Value
End Set
End Property

Sub New(ByVal DDL As HtmlInputText)
Me.m_DDL = m_DDL
End Sub

End Class

Public Class FormDictionary
Inherits DictionaryBase

Sub add(ByVal key As String, ByVal D As Object)
Me.Dictionary.A dd(key, D)
End Sub

Sub remove(ByVal key As String)
Me.Dictionary.R emove(key)
End Sub

Default Property item(ByVal key As String) As Object
Get
Return Me.Dictionary.I tem(key)
End Get
Set(ByVal Value As Object)
Me.Dictionary.I tem(key) = Value
End Set
End Property

Function contains(ByVal key As String) As Boolean
Return Me.Dictionary.C ontains(key)
End Function
End Class

Basically the 3 types of objects i want to pass from my page into a function
defined in another class are label, htmlinputtext and dropdownlist.

and i have this code in my form

For Each ctrl In pnlForm.Control s
If TypeOf ctrl Is HtmlInputText Then
frmDict.add(ctr l.ID, New FrmTxt(CType(ct rl,
HtmlInputText)) )
End If
If TypeOf ctrl Is Label And ctrl.ID <"" Then
frmDict.add(ctr l.ID, New FrmLabels(CType (ctrl,
Label)))
End If
If TypeOf ctrl Is DropDownList Then
frmDict.add(ctr l.ID, New FrmDDL(CType(ct rl,
DropDownList)))
End If
If TypeOf ctrl Is suppliersList Then
frmDict.add(ctr l.ID, ctrl)
End If
Next

This adds each of the objects into the dictionary however i cant get the ID.
I am using the syntax ctype(frmdict.i tem("lblReqBy") , label).ID but it
returns nothing.

I have a web user control on their (SuppliersList) which contains a
dropdownlist, i haven't created a class for this as its only on the page
once, if i use the following syntax

ctype(frmdict.i tem("Suppliers1 "), suppliersList). Controls.Item(0 ).ID

It gives me the ID of the dropdownlist. Can anyone help me out as to why I
can't access the ID property of the controls. Basically I will populate the
text property, selectedvalue property in a function i am writing and modify
the page appropriately, the reason i am doing this is because the same
routine is used on two of my pages and i only want to write it once and stick
it in a class.

TIA
Jul 5 '06 #1
1 1549
Hi i have played around with it this morning and noticed that each of the sub
new in the class was wrong so i changed it to read me.m_lbl = lbl. However i
still had the same issues described

Sub New(ByVal lbl As Label)
Me.m_Lbl = m_Lbl
End Sub

i also changed my for next loop to read

For Each ctrl In pnlForm.Control s
If TypeOf ctrl Is HtmlInputText Then
frmDict.add(ctr l.ID, ctrl)
End If
If TypeOf ctrl Is Label And ctrl.ID <"" Then
frmDict.add(ctr l.ID, ctrl)
End If
If TypeOf ctrl Is DropDownList Then
frmDict.add(ctr l.ID, ctrl)
End If
If TypeOf ctrl Is suppliersList Then
frmDict.add(ctr l.ID, ctrl)
End If
Next

This appears to be working ok, run a few tests in the immediate window. In
my vb.net book it says to create classes like i have done and add them to a
dictionary or collection object. I think the idea is to create early bound
objects i remember something about how it would operate faster, although
there must be something wrong in what i have written so far.

TIA

"steven scaife" wrote:
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
Set(ByVal Value As Label)
m_Lbl = Value
End Set
End Property

Sub New(ByVal lbl As Label)
Me.m_Lbl = m_Lbl
End Sub

End Class

Public Class FrmDDL
Inherits DropDownList
Private m_DDL As DropDownList

Public Property DDL() As DropDownList
Get
Return m_DDL
End Get
Set(ByVal Value As DropDownList)
m_DDL = Value
End Set
End Property

Sub New(ByVal DDL As DropDownList)
Me.m_DDL = m_DDL
End Sub

End Class

Public Class FrmTxt
Inherits HtmlInputText
Private m_DDL As HtmlInputText

Public Property DDL() As HtmlInputText
Get
Return m_DDL
End Get
Set(ByVal Value As HtmlInputText)
m_DDL = Value
End Set
End Property

Sub New(ByVal DDL As HtmlInputText)
Me.m_DDL = m_DDL
End Sub

End Class

Public Class FormDictionary
Inherits DictionaryBase

Sub add(ByVal key As String, ByVal D As Object)
Me.Dictionary.A dd(key, D)
End Sub

Sub remove(ByVal key As String)
Me.Dictionary.R emove(key)
End Sub

Default Property item(ByVal key As String) As Object
Get
Return Me.Dictionary.I tem(key)
End Get
Set(ByVal Value As Object)
Me.Dictionary.I tem(key) = Value
End Set
End Property

Function contains(ByVal key As String) As Boolean
Return Me.Dictionary.C ontains(key)
End Function
End Class

Basically the 3 types of objects i want to pass from my page into a function
defined in another class are label, htmlinputtext and dropdownlist.

and i have this code in my form

For Each ctrl In pnlForm.Control s
If TypeOf ctrl Is HtmlInputText Then
frmDict.add(ctr l.ID, New FrmTxt(CType(ct rl,
HtmlInputText)) )
End If
If TypeOf ctrl Is Label And ctrl.ID <"" Then
frmDict.add(ctr l.ID, New FrmLabels(CType (ctrl,
Label)))
End If
If TypeOf ctrl Is DropDownList Then
frmDict.add(ctr l.ID, New FrmDDL(CType(ct rl,
DropDownList)))
End If
If TypeOf ctrl Is suppliersList Then
frmDict.add(ctr l.ID, ctrl)
End If
Next

This adds each of the objects into the dictionary however i cant get the ID.
I am using the syntax ctype(frmdict.i tem("lblReqBy") , label).ID but it
returns nothing.

I have a web user control on their (SuppliersList) which contains a
dropdownlist, i haven't created a class for this as its only on the page
once, if i use the following syntax

ctype(frmdict.i tem("Suppliers1 "), suppliersList). Controls.Item(0 ).ID

It gives me the ID of the dropdownlist. Can anyone help me out as to why I
can't access the ID property of the controls. Basically I will populate the
text property, selectedvalue property in a function i am writing and modify
the page appropriately, the reason i am doing this is because the same
routine is used on two of my pages and i only want to write it once and stick
it in a class.

TIA
Jul 6 '06 #2

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

Similar topics

4
4298
by: Eric | last post by:
Hey Everyone.. I have a form that has approximately 7 text fields and 1 checkbox. Generally when this form is submitted(to itself BTW) it works fine, however, when the checkbox is only field that has been modified/clicked the form doesn't always submit. When it does work, a Stored procedure is passed form variables and updates to the db are made. When it doesn't, its as if the form wasn't submitted, it reloads and resets the page, but...
4
2070
by: Dan | last post by:
I'm trying to write a Windows application that obtains information from a web service. I can access the web service successfully, but I can't access the object returned by the web service in different forms. My application is something like this: MainForm.vb: Public Class MainForm
16
11882
by: David Lauberts | last post by:
Hi Wonder if someone has some words of wisdom. I have a access 2002 form that contains 2 graph objects that overlay each other and would like to export them as a JPEG to use in a presentation. I can do this individually for each graph but this does not help me as I need both on the same JPEG. I thought I would try an export the form that contains both but I am having trouble. (My VBA is self taught and a little knowledge is...
2
1539
by: JJ L. | last post by:
Hello. I have a project that consists of nine different objects, each serving their own purpose. In the past I have just created a form for each one, and then whenever you call, say, object.Display(), it would call up the form associated with that object. This form only displays information, it doesn't allow the user to edit any information. Is it possible to find the properties of a certain object, and then loop through creating labels...
0
3151
by: hellind | last post by:
When the form is submitted as ENCTYPE="multipart/form-data" using AspUpload component, I understand to use Upload.form("") to retreive the form elements. But I cannot retreive it from inside a class. Anybody can help? The form page goes to upload.asp, where inside upload.asp it calls the class which reads the form element and return back the values. Here is the code of the class. Class pluginFileTransfer Public path,...
2
1558
by: Jerry Spence1 | last post by:
One way of passing data to a thread is to encapsulate the thread inside a class. However, I can't refer to my main form objects from within the class/thread as it says "Reference to a non-shared member requires an Object reference". How do I refer to items such as Textbox1.text etc on my main form? -Jerry
1
2469
by: Dave | last post by:
I have multiple forms that will create an object. Basically a energy efficiency measure object. The measure object will have a couple of required properties set but after that it can have 10-20 different fields that are optional per measure. How do I account for the different fields that will be posted from the different forms when I create the measure object? Should I create a constructor method with just the required fields as the...
5
4236
by: Rob | last post by:
I have a control (Button) on a Parent form which opens a Windows form... all I want to do is pass a value from the child form back to the parent... it should be so simple... i.e. ParentFormName.Textbox1.text=ChildFormName.TextBoxWhatEver.Text... but nothing like this works. Any ideas ?
7
4162
by: SjaakBanaan | last post by:
Hey guys (m/f), I've got a problem that's been having me pulling out hairs and losing sleep quite some time now. The thing is this. I have a container form with a subform control. This control can take several sub forms as its source object. To make the information, that is generated on one sub form, available to a later sub form, I'm trying to store data in public variables and objects of the container form. In other words, I'm using...
0
9669
marktang
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...
1
10156
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9997
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 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...
0
9030
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, 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...
0
6776
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();...
0
5559
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4110
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
2
3718
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2916
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.