How To Declare The Custom User Controls

May 12, 2010

I am getting this annoying warning message "Object reference not set to an instance of an object." all the time because I created several custom user controls and drag it to a Windows form in a vb.net Windows application. I am using vs 2005 and dot.net framework v 2.0. This message pop up when I try to save the projector when I try to debug it in the Design mode.

View 2 Replies


ADVERTISEMENT

Custom User Controls - Correct Size With User Choice

Sep 27, 2011

I have some custom user controls in my .net winforms program that do not display correctly when the user has selected larger text size. This setting:

My controls look like this:
Instead of like this:

The bill to area and ship to area are both custom controls. I don't know if this is contributing to the problem but I do have code in each to scale the phone/fax areas to stretch nicely, like this code from the bill to control,

Private Sub panFaxPhone_Resize(sender As Object, e As System.EventArgs) Handles panFaxPhone.Resize
panFax.Width = (panFaxPhone.Width / 2) - 1
panPhone.Width = (panFaxPhone.Width / 2) - 1
panFax.Left = panFaxPhone.Width - panFax.Width
End Sub

How can I get my controls to size correctly while still respecting the users choice for larger text (I don't want to just set the AutoScaleMode to None)? After playing with this for a long time it seems to be a problem with anchors in the child controls. See this below image, the inner black box is the control with its border turned on, the text boxes (like name) are anchored left and right and should stretch to fill the control, but don't.

View 1 Replies

Serving Custom User Controls On Webpages?

Jun 28, 2009

I have a UI hosted on a webpage. I'm able to run the control on the server hosting it, but when I attempt to run it from other machines on the intranet, only some of the required DLLs make it to the client.

View 1 Replies

Automatically Declare Controls As Private?

Mar 10, 2009

I find that 98% of the time, any work I do with a Control on a From, I do within the form's class. Visual Studio automatically declares all of those controls as Friend, but there really isn't a need.Is there a way to have Visual Studio automatically declare all controls as Private and I can expose any controls as Friend as needed?

View 2 Replies

Manage A Large Number Of Similar Controls In A User Interface (such As Button Or TextBox Controls)

Aug 23, 2011

There is newer code in a follow up post. I suggest using the code in the later post rather than the code in this one. You can still read this post though. When designing a user interface, one should be conscious of how many individual controls are required to implement the functionality. In some cases an initial design may begin with many buttons or textboxes (for example) but then further review of
the actual required functionality allows for a reduction in the number of unique controls.

But other times, there isn't a better way (which will still make sense to the user of the application) then to have a series of many repeated controls. So in the cases where one can be certain that the best UI implementation for an application will require the use of multiple copies of a given control, then it often becomes necessary to maintain some method of managing all of those controls at various points
throughout the application. Doing so typically requires that one build up some collection of controls which can then be accessed by index in order to work with any given control; but this can lead to a lot of clutter in the code file which handles these control's events. For instance there will be some kind of collection declaration, some recursive routine to find all of the controls of interest, and then any number of event handler methods with long lists of Handles clauses, or additional code loops to wire up the event handling for each control.

Purpose Since most of this functionality could be considered a requirement regardless of the type of control being managed, or its required functionality, it may make sense to wrap all of the control management functionality into a single class. And since our first requirement is a collection of controls, then a base collection class could be the perfect starting point for our control manager. There are a number of existing thread around this topic, with some recent (at the time of this writing) ones being:[URL]..In this, and related, threads I have posted examples of a simple TextBoxManager and ButtonManager control. But again, with so much similar functionality required regardless of the control being managed, it would be technically possible to create a generic ControlManager(Of T As Control) class which can manage any type of control.

[Code]...

So in summary, one can facilitate managing a large number of user interface controls by building a "control manager" class which both encapsulates the list of control instances, and deals with adding and removing defined event handlers for every control it manages. The generic control manager class itself can be inherited and extended into a more specific class on a per-application basis in order to provide more application-specific functionality. Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

View 9 Replies

Declare A Variable As A String That Is = To The User's Input?

Mar 9, 2012

I simply just to declare a variable as a string that is = to the user's input, and I thought that was done by this:

dim xxx as string =("skdlfjaofhhwa")

But it's not working?

View 1 Replies

Declare "custom Command" In Visual Basic 2010?

Jan 13, 2011

I'd like to, let say "declare" my custom command, and what do I mean by command is something you type in the code, when for example you click a button. Just like Textbox (for example), my custom command sould have "underthings" in it, so just like I can type in Textbox1.Text. And that underthing (in this example, textbox is my custom command and .text is a sub/underthing) I can set if it is a boolean or string etc. I need this for my login program, where that custom command is an username (named username, what you can dim), and then it has sub things, like username1.email (string for e-mail text) and username1.password, username1.ismoderator (boolean, true or false). So an example, in my program I can do like this:

'Username is my custom command, just I don't know how to'define or declare it.'Username has here, to keep it simple, 2 sub things, it is'username.password and username.name Private Sub btn_registrate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_registrate.Click'When the button called registrate (make new username) is clicked Dim username1 As Username'(I don't know if it must be dim blabla as NEW or without new with'my custom command)username1.name = Textbox1.Text 'Textbox for username username1.password = Textbox2.Text 'Textbox for password

View 3 Replies

Use Parent User Controls From Externally Loaded User Control?

Jun 2, 2012

i have a windows from project and in that project i created a user control lets call itcustombutton1 now i can use that control quite easily either at design time or runtime by creating a new instance of it like

View 1 Replies

Declare Properties/Events Such As IsPostBack/Init On An Interface That A User Control Will Implement?

May 2, 2012

I'm having trouble porting some .NET2-era C# to .NET2-era VB.NET. Specifically, I am trying to define an interface that an ASP.NET user control will implement.(For background, I am trying to re-implement Phil Haack's Model-View-Presenter example from several years ago: http://haacked.com/archive/2006/08/09/ASP.NETSupervisingControllerModelViewPresenterFromSchematicToUnitTestsToCode.aspx)

The C# interface I'm working from defines properties and events (IsPostBack, Load) that are already implemented by the base control.However, VB.NET is forcing me to explicitly implement these properties/events in the user control (Public Property IsPostBack() As Boolean Implements IView.IsPostBack...). I'd like to just define these in the interface and not have to do anything special in the code-behind of the implementing user control.I'm assuming that I can do this in VB.NET, I just don't know how. I've spent all sorts of time googling/bing-ing, and haven't come up with the answer.

View 1 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

VS 2008 Controls Vs User Controls

Dec 2, 2009

How many controls can I have before I should start looking at user defind controls because of too many controls making my program go slow?

View 4 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 - .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

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

Inherit From Custom Controls VS 2008

Nov 16, 2009

Is this possible? Must be surely but I've tried and come up short. I've created a very basic class (person) with 2 public properties, forename, surname. My user control is databound to this class and has 2 textboxes to store the properties.

I've built the control and can add the user control to a windows form but how can I add to a new user control (Staff) which will show my 2 existing textboxes and I can add dateJoined datepicker also??

View 6 Replies

Looping Through Custom Controls On A Form?

Dec 4, 2009

I have created a customised checkbox control (only the text and border appearance has been modified), and wanted to loop through them in a User quizto see which have been checked and are correct. I have used the Tag property (set to 1 or 0) to identify incorrect answers, and tried to loop through with the following code:For Each thing As GMAW.MyCheckBox In currentParent.ActiveMdiChild.Controls

View 7 Replies

Make Custom Controls Available To All Projects?

Aug 6, 2009

I have some custom controls in a specific project. I want to make these controls available to ALL my projects. How do I do this?

View 5 Replies

VS 2008 Custom Controls In Toolbox?

Jun 23, 2010

I got a third party control from a website after googling.Inorder to use that control, I simply right-clicked the Toolbox and selected "Choose Item". Then Browse to that dll file location and selected that file.Now it is added to the toolbox. But do I have to register the dll now ? Or, will it work when I distribute my app ?

View 6 Replies

VS 2010 Creating Custom Controls?

Aug 23, 2010

I got this whole thing pretty well down (it's actually quite easy), but I've seen custom controls created where you can click that little arrow on the top-right corner and add things or change things about it.

How exactly is this done? I'd Google it (which is why you don't see me post here too often) but I really don't know how to describe it.

View 1 Replies

What Is The Best Reference Material On WPF Custom Controls

Aug 24, 2009

I currently do all development work in VB.NET 2008, winforms; but within 18 months will be switching to WPF (for better or worse). I have had great success using Matthew MacDonald's "Pro NET 2.0 Windows Forms and Custom Controls in VB 2005" book. This is an excellent reference focused entirely on the development of custom controls in windows forms. ( Many of the controls that I use have to have a very specific UI look and feel, so they end up being custom.

I'm looking for pretty much the exact same thing, except focused on WPF. MacDonald has a new book coming out on WPF in general ,but not on custom controls. Books are my preferred reference material, but any good web references.

View 1 Replies

Working With Properties In Custom Controls?

Feb 1, 2011

I am trying to learn how to create Windows Forms custom controls in VB.Net by creating a .Net version of an old control I created in VB6. On this control, I have a UserControl with a Label (lblCaption), and several of the properties I add to the control should be passed to the label.This is the code I tried for the ForeColor property:

Code:
Protected mcolForeColor As Color = Color.FromKnownColor(KnownColor.ButtonHighlight)
Public Overrides Property ForeColor() As Color
Get

[code]....

When I change the ForeColor on the control in my test project, lblCaption does change to the color I selected; however, when I run the application, the label changes back to the default (button highlight) color, and the value of the property is also reverted back when I return to the form designer.What would be the proper way to implement the ForeColor property on a custom control?

View 4 Replies







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