473,766 Members | 2,130 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Generelized Code

How same functionality can be given to mulitiple forms in a VB.Net
project?
e.g. Suppose on each form, toolbar is present. If we click on New
button then Add, Edit button gets disabled and Save, Cancel button is
enabled. If we click on Save button, records gets saved.
In short how the generelized code can be written?

Feb 22 '06 #1
3 1180
Anil,

If it's something that appears on multiple forms, I'd either create a User
Control composed of the constituent controls and plonk it on each form
required, or I'd create the toolbar on a 'master' form and use visual
inheritance to have it appear on your child forms.

HTH,

Adam
--
Adam May
Sydney, Australia
MCSD.Net
"Anil" wrote:
How same functionality can be given to mulitiple forms in a VB.Net
project?
e.g. Suppose on each form, toolbar is present. If we click on New
button then Add, Edit button gets disabled and Save, Cancel button is
enabled. If we click on Save button, records gets saved.
In short how the generelized code can be written?

Feb 22 '06 #2
Thank you sir, What idea U have gievn will be definitely helpful for
me.

But my second problem is how (outline) modules can be written to
provide functionality e.g. saving,updating of records throu various
forms.

I tried to implement shared methods in modules to access those without
instance creation. Then pass argument to recognize which form is
calling that shared method. But I feel its not the right way.

So please give me proper direction.
once aggain Thanks a lot sir.

Feb 22 '06 #3
Hi Anil,

Let me see if I understand you correctly - you're asking how top create a
method that can be used across multiple forms?

If the forms are all similar, I'd use visual inheritence. For this example,
I've created three forms - one parent form (ParentForm.vb) and two inheriting
child forms (ChildForm1.vb and ChildForm2.vb).

The parent form has the data save method (SaveData). This can be called from
any of the three forms, but for ease of use, I've created a button on the
parent form that calls the code. This would then be inherited by the children
forms.

Here's the code:

ParentForm.vb
-----------------
Public Class ParentForm
Inherits System.Windows. Forms.Form

' Removed Windows generated code for brevity

Protected Sub SaveData()
'Save your data here
End Sub

Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
SaveData()
End Sub
End Class

ChildForm1.vb:
-----------------
Public Class ChildForm1
Inherits WindowsApplicat ion2.ParentForm

' Removed Windows generated code for brevity

End Class

ChildForm2.vb:
-----------------
Public Class ChildForm2
Inherits WindowsApplicat ion2.ParentForm

' Removed Windows generated code for brevity
End Class

As you can see, there's no code in either of the children forms to do the
save data - that's all inherited from the parent (base) class. If you need
need to call the parent's SaveData method from the children, it's still
possible by using MyBase.SaveData ().

Hope this example helps you along your way.

Adam

--
Adam May
Sydney, Australia
MCSD.Net
"Anil" wrote:
Thank you sir, What idea U have gievn will be definitely helpful for
me.

But my second problem is how (outline) modules can be written to
provide functionality e.g. saving,updating of records throu various
forms.

I tried to implement shared methods in modules to access those without
instance creation. Then pass argument to recognize which form is
calling that shared method. But I feel its not the right way.

So please give me proper direction.
once aggain Thanks a lot sir.

Feb 22 '06 #4

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

Similar topics

51
5285
by: Mudge | last post by:
Please, someone, tell me why OO in PHP is better than procedural.
9
3865
by: bigoxygen | last post by:
Hi. I'm using a 3 tier FrontController Design for my web application right now. The problem is that I'm finding to have to duplicate a lot of code for similar functions; for example, listing users, and listing assignments use similar type commands. Is there a "better" way I can organize my code?
4
2434
by: jason | last post by:
Hello. Newbie on SQL and suffering through this. I have two tables created as such: drop table table1; go drop table table2; go
16
3112
by: Dario de Judicibus | last post by:
I'm getting crazy. Look at this code: #include <string.h> #include <stdio.h> #include <iostream.h> using namespace std ; char ini_code = {0xFF, 0xFE} ; char line_sep = {0x20, 0x28} ;
109
5926
by: Andrew Thompson | last post by:
It seems most people get there JS off web sites, which is entirely logical. But it is also a great pity since most of that code is of such poor quality. I was looking through the JS FAQ for any question that identifies the warning signs to look out for, the things that most easily and clearly identify the author of code as something less than a master of the art. I did not find an FAQ that answered it, but I think the FAQ
5
4068
by: ED | last post by:
I currently have vba code that ranks employees based on their average job time ordered by their region, zone, and job code. I currently have vba code that will cycle through a query and ranks each employee based on their region, zone, job code and avg job time. (See code below). My problem is that I do not know how to rank the ties. Right now if two people have the same avg time one will be ranked 3rd and the other ranked 4th. I would...
0
2095
by: Namratha Shah \(Nasha\) | last post by:
Hey Guys, Today we are going to look at Code Access Security. Code access security is a feature of .NET that manages code depending on its trust level. If the CLS trusts the code enough to allow it ro run then it will execute, the code execution depends on the permission provided to the assembly. If the code is not trusted wnough to run or it attempts to perform an action which doe not have the required permissions then its execution...
18
3162
by: Joe Fallon | last post by:
I have some complex logic which is fairly simply to build up into a string. I needed a way to Eval this string and return a Boolean result. This code works fine to achieve that goal. My question is what happens to the dynamically created assembly when the method is done running? Does GC take care of it? Or is it stuck in RAM until the ASP.Net process is recycled? This code executes pretty frequently (maybe 4 times per transaction) and...
37
5989
by: Alan Silver | last post by:
Hello, Newbie here, so please forgive what is probably a basic question ... I see a lot of discussion about "code behind", which if I have understood correctly, means that the script code goes in a separate file from the HTML. Apart from the obvious advantage if you have a separate designer and programmer, are there any other advantages to code behind? Most of the stuff I've seen so far uses code inside, but that's probably
0
9571
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...
0
9404
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10168
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, 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...
1
9959
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,...
1
7381
isladogs
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...
0
6651
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
5423
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3532
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2806
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.