Custom Controls - .net Inherits 2 Classes?

Jan 16, 2012

inherit from two classes in VB.net?We are developing Custom User Controls that inherits from say System.Web.UI.WebControls.Label. We are planning on implementing a bunch of these controls but they will share mostly the same additional properties. We are hopeful about centralising these properties.I have looked into interfaces but it seems they only 'contract' properties you need to implement.

View 2 Replies


ADVERTISEMENT

Best Pratice In Inheritance - Three Classes Employee, Manager And Salesman. Manager And Salesman Classes Inherits Employee Class

Jul 27, 2010

I have three classes Employee, Manager and Salesman. Manager and Salesman classes inherits Employee class.

Employee :

Public MustInherit Class Employee
' Field data.
Protected empName As String
Protected empID As Integer
Protected currPay As Single

[CODE]...

Manager :

Public Class Manager
Inherits Employee

[CODE]...

Salesman :

Public Class Salesman
Inherits Employee

[CODE]...

Now I have created a object of salesman and manager using the following code:

Dim objSalesMan as Employee=new Salesman("xyz",1,2000,5000)
Dim objManager as Employee=new Manager("abx",2,5000,"production")

Is this a good programming pratice or should I use:

Dim objSalesMan as new Salesman("xyz",1,2000,5000)
Dim objManager as new Manager("abx",2,5000,"production")

View 6 Replies

Creating Custom Control By Inherits BindingNavigator - How To Add ToolStripItem By Code

Sep 28, 2010

I'm creating a custom control which inherets the BindingNavigator.I need do add one ToolStripButton at specific posistion (9 element) on the ToolStrip of the BindingNavigator.So, I wrote the following code:

[code]...

View 7 Replies

VS 2008 Displaying Text On Custom Control (Inherits ListBox)?

Mar 24, 2010

So, I'm working on a custom LitBox that accepts custom items. needed the item collection to be more than just strings, I needed to be able to store avalue to display in the listbox and an associated value (Property: Text) that holds an index value (Property: Tag) of DataTable I'm working with.I have created the new item (iListBoxItem) and the collection (iListBoxItemCollection) and have modified everything so that I can do normal Collection type methods (Add, InsertAt, RemoveAt, etc) to this collection.

vb
Imports System.ComponentModel
Public Class iListBox

[code].....

View 3 Replies

Difference Between C# And Custom Classes

Sep 1, 2011

I have been out of VB.Net way too long, I have a custom class in C# that needs to be converted to VB.Net and would like to know the main differences between them. Certain things in C# I cannot seem to do in Vb.Net with classes such as use: public classname or public [classname](DataTable dt) in VB.net

M[Code]...

View 3 Replies

Working With Custom Classes?

Dec 16, 2010

I already know how to make really basic custom controls where I can pass in new variables to treenodes because of my custom class, but it's not really working out well for me.I figured out how to read the new values & change them while their in the normal treenode because oddly enough once i've passed in an object from my custom treenode class it worked but I want to know a few things.

1.With my custom class, I can't do things like the following.

MsgBox(
New
TreeNode("Today").IsSelected)

If I replace with CustomTreeNode it doesn't work no matter what I do even working with sub/new it always shows a default value instead of what value is, the most I can think of is because sub isn't returning value, but you can't return value in subs, how are you meant to make lines like that work?

2.Also anyways just for sake of having good intellisense & workings is there a way I can make a class of CustomTreeView that's using my CustomTreeNode's so that I can work on things by code in the EXACT same manor I used to given the name is the same but have my new custom values?Currently im stuck passing any changes using the new type & taking it out I type cast over to the custom type again so i can read the values, but I just want was wondering what I need to do to make it work like a real control would.

Anyways is there any way to over-ride the default control or something instead so I can simply add the new variables in there? I want the same functionality of the normal control just with the added variables so I can work with data pertaining to the nodes of each item in the treenode easier.I already used the Tag value to store some information but it's not like that there are 100 different variables to store information & it's not like anyone wants to store lots of values in 1 variable & parse out the one you need, it's possible but if I can create something good here, I want to use whatever I can make instead of taking my time on working on a more painfully difficult to work with, at least later when I might even need even more variables stored pertaining to each of the items.

View 7 Replies

Converting Types Using Custom Classes?

Sep 16, 2009

I'm studying for the MCTS exam 70-536 and have come across the following question:Given the following Visual Basic code sample, which interface must the custom class MyClass implement?

Dim a As MyClass, b As Boolean
a = 42
' Convert using ToBoolean.
b = Convert.ToBoolean(a)
Console.WriteLine("a = {0}, b = {1}", a.ToString, b.ToString)

Before even looking at the possible answers, I can't get past WHY on earth would we be converting the number 42 to a Boolean value?? I tried this and as I suspected it did NOT compile! Is this a trick question or am I missing something? I realized that in order for the code to work, I would need to implement one of the interfaces shown in the multiple choices. STILL, would there EVER be a purpose for this particular conversion?

View 4 Replies

Looping Through Custom Collection Classes

Oct 5, 2011

I have a custom collection class. The main member of the class is a List(Of T). I did what this article says: [URl] For some reason though I can only foreach my collection once. The second time it tries it goes out of range because the position does not reset after the first foreach. What am I doing wrong?

[Code]...

View 4 Replies

Find All The Classes Of The .net Controls?

Aug 15, 2009

How do i find all the classes of the .net controls for example how do i see the class of the button control?

View 13 Replies

.net - Arraylist Of Custom Classes Inside My.Settings?

Oct 17, 2010

I have a Visual Basic .Net 2.0 program. I'm moving the settings from an older settings file, to an app.config program settings file. I'm trying to do this as nicely as possible.

So, I added my setting as shown in this image.

On load I do this:

If My.Settings.databaseConnectionSettings Is Nothing Then
My.Settings.databaseConnectionSettings = New ArrayList()
End If

[Code]....

So, the question is, how do I get that arraylist of my DatabaseConnectionSettings saved to persistent storage? I want to do this in the cleanest way possible. That is, I don't want to have to convert it to a string or save it to a separate file every-time I want to use it. I would like to be able to use the My.Settings accessor method.

View 1 Replies

DataGrid To Display Custom Classes Via A BindingSource

Jul 9, 2011

I'm using a DataGrid to display the below custom classes via a BindingSource, I'm trying to figure out a way to save them to a file either by serialization or by some other method. I've tried a lot, but I think it has a hard time serializing because the Account object has the CharacterList object or something. [code]

View 3 Replies

Possible To Use Generics To Populate List With Custom Classes?

Jul 10, 2009

I have several different lists I want to call. They all have the same format for the class:
id, value, description, order.
Instead of creating a bunch a classes to return the all of the many lists, I wanted to use generics and just tell it what kind of list to return. However, I can not figure out how to populate the classes.

Here are 2 examples of function in my calling code. This should indicate the type of list and the stored proc used to get the data:
Public Function getTheEyeColors()
Dim glEyeColors As New GenericList
Return glEyeColors.GetALList(Of EyeColor)("GetAllEyeColors")
End Function
[Code] .....

View 4 Replies

ASP.Net - Accessing Controls From Separate Classes?

Jun 23, 2010

I have an ASP.NET Web Site I am creating in Visual Web Developer 2008 Express using Visual Basic as the language. It is actually a rewrite-with-mods of an existing ASP script and I'm trying to chew what I've bitten off. I created my page with a text box (txtOutput) on it and since the end product is very complex, and it's generally good practice to separate like functions, I have created 4 separate classes in the App_Code section. My main page is Sync.aspx and has a code file Sync.aspx.vb with it. One of my code files is SyncDatabases.vb and in it I have created

Public Class SyncDB

In that class I have created some routines such as

Public Function ReadMSDB(ByVal SQLString as string) as Boolean

In this routine I want to put information in my text box txtOutput on the main form (the default - Form1).

My problem is that if I try:

Form1.txtOutput.Text = "Hello world"

or just

txtOutput.Text = "Hello world"

it says Name 'Form1' (or 'txtOutput') is not declared. I am sure I am missing something simple but have no clue what it is. I assume it's the fact that the write command is in a file (class?) outside the file (class?) containing the page itself but I don't know how to address it properly.

View 4 Replies

Add Classes And Custom Form With Code In A Setup Project?

Jul 22, 2010

I have a main application and the setup project for the app in a single solution.I have custom classes to detect in sql server 2005 express is installed. if it is not I have classes to install it and create my database.Now I need to call the above classes from my setup project before it installs my actual application on a client pc.

View 2 Replies

Winforms Data Binding: Custom Classes Or Datatable?

Jul 8, 2009

Am in the process of architecting a new windows forms application, and I intend to use Visual Basic 2008 and SQL Server Express 2005. This is my first application in .Net and I really want to observe the best OOD & OOP principles to create an application that is easy to maintain and extend (add new functionality). My issue is in regard to databinding on the UI. From experience, what do you guys recommend to use for databinding? Should I return datasets/datatables from my Business Layer and bind these to UI controls or should I return Business Objects and bind these to UI controls? And what are the pros and cons of each approach?

View 1 Replies

Throw System.Exceptions From Within Custom Classes To Calling Code

Jul 9, 2010

I Have just been watching a video on throwing Exceptions. Are you supposed to throw System.Exceptions from within your custom classes. to the calling code, Which other way can they communicate. I have read in several places it is bad practice to throw SystemExeptions.

View 3 Replies

VS 2005 - How To Make Custom Base Classes Available To Future Programs

Oct 22, 2010

I have written multiple programs in the past that deal with cad data. Points, lines, arcs, etc. For each program I ended up creating slightly different versions of some really base classes like a class that defines a point:

<Serializable()> Public Class Point
Public x As Double = 0
Public y As Double = 0
Public z As Double = 0
End Class

My question is how would I use that class in such a way that it could be in a namespace and imported into any future project that I write?

View 2 Replies

Using Inheritance-Based Controls - Creating As New Classes (not UserControls) Inheriting From An Existing System Control

Oct 15, 2011

I seem to be having a problem with controls that I am creating as new classes (not UserControls) inheriting from an existing system control. Everything seems ok while I create the control code, through to the compile (which is successful and adds the control to the toolbox) and dragging the control from the toolbox to the GUI surface. However, when I then debug or compile the project, I get a message such

[Code]...

View 2 Replies

Custom Tab Controls In .net?

Mar 27, 2010

i want to control my tab pages with custom buttons...now i want to hide my tabs from tab controls...

View 2 Replies

How To Add Custom Controls

Aug 1, 2010

I want to know how to add custom controls to vb.net.

View 6 Replies

.NET For Each Exception On Custom Controls?

Dec 9, 2011

in VB.NET i have 2 custom controls, one is a TextBox and second one is a ComboBox.These have custom values like Bool _IsHidden and are added on runtime to a form.Now, at some point in the code I want to check if the _IsHidden is set to True or False and display that information. Since the user can edit this values when creating the control these are not set on creation.

So what I tried is:(all of this is on MDI Forms)

For Each frm as CustomForm in Main.MdiChildren If frm.MyName = calledBy Then 'this part is just to know which form called the form to create the object For Each cntrl as CustomTextBox in frm.Controls'DO Something
Next End if Next

Now.. if the first control is a custom ComboBox it thorws an error since it sees that it does not match the custom TextBox control..how do i get around this? By my understanding it should just go through all of the controls on the said form and just check those who match CustomTextBox control ?

View 2 Replies

Arguments For Custom Controls?

Nov 24, 2011

I've created custom buttons in a .dll and they work fine, so I thought I'd have a go at creating my own sort of listbox to replace the standard one in my applications. It's basically a panel with a few labels and a button (eliminating the need to select an item in standard listbox then click a seperate button). I want to add these panels to a panel on a form, at run-time, based on rows in a db.

If I try adding any arguments in the New() section of the class file it won't let me use the panel in my toolbox. Is there a way to pass arguments to custom controls, I need a new custom panel for each row in a db so need to pass an id to it to specify records; or even load the records in my application and create a new panel for each record, using info passed to it to fill in the labels on it. Or can I create the panel at run-time and refer to labels within the custom controls, setting their .text properties that way?

View 5 Replies

How To Create Custom UI / Controls

Mar 19, 2011

I would like to expand my knowledge of VB.NET and was looking at creating custom user interfaces or custom controls. The type of things I am thinking of is: [URL]s. How are those controls created? I imagine it involves using the existing controls in Visual Studio as a starting point, and altering them to suit your design?

View 2 Replies

Resizing And Custom Controls?

Dec 10, 2010

I'm not going to post my code for my transparentlistbox class, but here is a link to it.It's been working fine as is, until early this morning when I tried to set a different size.[URl]..For the longest time I placed a normal listbox control on a form and resized that, setting a new public variable of transparentlistbox to the same size/location as the original listbox, setting the visibility of the original to false, and adding the transparentlistbox to the form (me.controls.add).It looked like this:

[Code]...

Now, since I've moved some buttons around on my main form, I resized the original listbox control to be wider (same height though). When I tested, the transparentlistbox (code didn't change still set to original listbox size/location), the size was that of what I had the original listbox set to, before resizing?

So, I commented out all of the custom drawing/paint events/etc I could find for the transparentlistbox and tested, still stuck to the original size. I stepped line by line debugging and verified that transparentlistbox1.size=listbox1.size indeed matched the new resized size (but didn't actually resize)?

Last I did was comment out the transparentlistbox.visible and put back the listbox1.visible and listbox1 does indeed show with the new resized size? I'm not quite sure what to test next?

View 2 Replies

Use SVG In .net To Draw Custom Controls?

Nov 3, 2009

Is there a way to use SVG in vb.net to draw custom controls? Or any other way?

View 3 Replies

Adding Controls To A Custom Control

Jun 19, 2012

Is it possible to have a custom control (inherits from Control) and add sub-controls to it (like, a label for example)? Basically I want a composite control. I know controls can contain other controls, but if I try to add a control to MyBase.Controls, this doesn't work because that's readonly.

[Code]...

View 2 Replies

Create Custom Controls For Apps?

Oct 14, 2011

i need to create custom controls for my apps so how can I do that? Do I need a special software to do that?

View 3 Replies

Custom Controls Disposing & Memory?

Apr 14, 2010

I've been working on a few large custom controls, and I noticed that when I use them, my memory starts ballooning. If I add a control at runtime, it increases the memory, but when I remove the control, it decreases less than it increased. However, it would stop balooning at some higher value. So if go back in forth between pages (which adds and removes the control), the memory would look something like this:

1,000K|5,000K|4,000K|9,000K|8,000K... 20,000K|25,000K|21,000K|25,000K|21,000K|25,000K... etc I know it takes a while for the GC to run, but the memory would stay consistantly high for long periods of time.

I tried writing a Closing routine, where when I called it, the control looped trhough its children and disposed all the internal controls, which seemed to help a little, but the memory after running the control and disposing was still much higher than before running the control. I also use custom event addhandlers. Should I remove all these as well. It would be nice if I received a little guidance on this.

View 2 Replies

Get A Primer On Creating Custom Controls?

Dec 2, 2009

I am new to VB 2008 having spent most of my time in 2003. What is the recommendation for the best place to get a primer on creating custom controls in VB.NET. I prefer to use VB directly and not the WPF.

View 2 Replies

Handling Focus With Custom Controls?

Nov 3, 2011

I have a custom control I'm creating. When I click on it, it draws a dotted border and puts some nubs on it for resizing. This all works perfectly. Now I want it so when I click off of it, it deselects. I already have a variable to set up if it's selected or not and subs to draw/clear it. I just have to be able to detect when something else is selected or it gets clicked off of.

What I've Tried

My first and best solution to this was to use the LostFocus event, but, by custom control apparently won't let it fire. After some research, as far as I know, custom controls don't have Focus events because they are custom and could be changed (basically, you have to implement the focus events yourself).

My Question

Does anybody have a solution to either implement the focus events or a way to handle off clicking for custom controls?

Sources

Here is my controls current source:

Imports System.Drawing.Drawing2D
Public Class wDOMElement
Inherits Control

[Code]....

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved