Winforms - Custom Constructors For Forms In .net?

Nov 1, 2010

I would like to open a new form from some other form, and pass some selected object from a control on that form to the new form. The sensible way to do this, I thought, was as a parameter to the forms constructor. Now I know that the visual studio GUI creates partial classes for my forms, that hold the properties that I can drag onto there in the designer. I assume it also holds a default constructor. Since it might do all sorts of stuff that is needed to initialise the form, I figured I should call it from my custom constructor ala

public sub new(byval my_parameter as Foo)
Me.new()
Me.my_parameter = my_parameter

[code].....

That clearly wasn't it, because it can't find a default constructor. The thing is, visual studio goes trough great lengths to prevent me from seeing the generated constructor, so I know how to access it. This leads me to believe that I am actually doing it wrong, and should have set out on some different path, as the path you are forced in to usually is the sensible thing to do, which I usualy find out way too late.

View 3 Replies


ADVERTISEMENT

Startup Forms And Constructors?

Mar 5, 2012

I was able to narrow down a problem to a certain point. I was hoping for an explanation or some light shed upon it. I went to Project/Project1/Application/Startup Forms. I found that when I included a "New" constructor in the form I wanted as startup, the form became unavailable for choosing as a startup form. I do not quite understand this because I noticed from work in another document that the form I want (call it StartupForm) actually has a basic "New" construction with no arguments, so that is why I do not understand quite what is happening here.

[Code]...

View 1 Replies

Type 'Sytem.Windows.Forms.TreeViewCollection' Has No Constructors

Oct 9, 2008

I just wanted to try something I had in mind,

Code:
Dim mTreeNodeCollection As TreeNodeCollection
mTreeNodeCollection.Add(New TreeNode("ddsf"))

above produces a 'System.NullReferenceException was unhandled' which is fine.

So I thought dam I forgot to initialise it!!

Code:
Dim mTreeNodeCollection As New TreeNodeCollection
mTreeNodeCollection.Add(New TreeNode("ddsf"))

Now it does not run but i get

Quote:

Type 'Sytem.Windows.Forms.TreeViewCollection' has no constructors

so how the hell I'm I going to get it to work?? can I only Add to a TreeNode collection , a TreeView?

View 4 Replies

Error: Type System Windows Forms Application Has No Constructors

Sep 28, 2010

I grabbed an example program to modify for my needs to grab data from a Word doc and transform to XML. Right off the bat I get multiple errors. [Code] I am getting Error Type 'System.Windows.Forms.Application' has no constructors.

View 6 Replies

Constructors Calling Other Constructors In La C#?

Oct 23, 2009

In c# you can have

public class Foo
{
public Foo(string name)
{
//do something

[Code]...

Is there a VB.Net equivalent?

View 1 Replies

Custom Sub Main For WinForms Applications?

Mar 3, 2011

I'm interested in building my own basic Application controller and ditching the Application Framework entirely.Never done this before (or even considered it) but now I'd like to be able to cut out anything that stands in the way of making my App compatible with both DotNET and Mono, for which Microsoft.VisualBasic.ApplicationServices is pretty famous.I start, or links to sample Main Modules for WinForms online? Seems like most of what I find is for Console apps.

View 8 Replies

VS 2008 Using Custom Membership Provider In WinForms?

Feb 8, 2010

I would like to use my custom membership provider (which is working in my asp.netapplication) in my windows forms application.I thought this would be relatively straight forward, and followed these steps:1. Copied MembershipProvider class into my application.2. Add reference to System.Web3. Create app.config with membership settings i.e:

View 3 Replies

Winforms - Adding A Custom Button In Title Bar?

May 30, 2011

I was just wondering if there was a possible way to add a custom button into the title bar using VB.NET. I've seen many such questions on Stack Overflow but failed to get a sure-shot and a working answer.

View 3 Replies

Winforms - Use Custom Roles For User Access?

Sep 2, 2009

I have a winforms (VB 2008) based app that I'm developing and I want to use custom roles for user access.Application Layout:I have a Main form that opens a login form when certain actions occur.The Login form intern uses an authentication class that I've created, to authenticate users and set access rights.On my Applications settings page, I have Authentication Mode set to Application-defined because I cannot use Windows Authentication in the environment where this will be deployed.

The application uses a MS SQL 2005 db and the 3 tables I'm using in the authentication process are the User_Account , User_Roles and User_Access tables. The combination of an account in the User_Account and the roles within the User_Roles table are the bases for the User_Access table. Using the User_Access table is how I assign access to the various functions within the application

Authentication Method:To authenticate a user, I'm using the "My.User.CurrentPrincipal" (Code below) method. The My.User object works great and allows the use of "My.User.Name" property throughout the app when referring to the currently authenticated user.

Access Method:In order to set the current users access levels I'm using a function within my Authentication class and passing in My.User.Name as a variable. The function uses a Dataset Table Adaptor and a Select Case statement inside a For loop to assign all the access levels for the user (Function code below).

My Problem:This method of assigning access rights to a user does work but it's not persistent throughout the application as the My.User object is.I would like to find a way to create custom roles through the My.User object using its .IsInRole property. I would like to have these roles dynamically created using my User_Roles table.This would allow the custom roles to be used throughout my application using the My.User.IsInRole ("MyRole")syntax ...similar to how I'm currently able to use My.User.Name.Unfortunately the only roles I can currently validate against are the built in Windows
type accounts (Adminisrator ...ect.).

'User Authentication example:
If Authenticate.CheckPassword(tbxUserName.Text, strPassword) Then
My.User.CurrentPrincipal = New GenericPrincipal(New GenericIdentity(tbxUserName.Text), Nothing)[code].....

View 1 Replies

.net - Create Custom DataTable Which Is Bindable To WinForms Controls?

Aug 25, 2011

Our shop primarily use "ADO objects" (I'm referring to DataSet, DataTable, and DataRow) for marshaling around data and manipulating it on forms and in grids. We are experimenting with creating shop-flavored counterparts to the native ADO objects so that we can impose our in-house standards on top of them. Implementing this is straightforward with one exception: I want our objects to be bindable to controls.

I'm aware of IList, IBindingList, BindingSource, etc. and have looked at and experimented with these, but I am falling short when it comes to making a class with no hard property names bindable. The native ADO objects are not strongly typed by default. You have column values that you access via the Item property (e.g. row("Age") or row.Item("Age")). The binding examples I've found online deal with strong-typed objects (e.g. row.Age). Essentially, we want to create custom ADO objects (not inherited from the native ones) that still retain their ability to bind to controls. In a grid I would expect to see columns Name, Age and Occupation from a row where these properties are exposed via row("Name"), row("Age") and row("Occupation"). This must be doable as this is exactly what the native DataTable and DataRow provide.

View 1 Replies

Develop A Custom WinForms Data Source Control?

Nov 6, 2009

How can I develop a custom data source control for WinForms ? This example is just for ASP.NET. VS version: VS 2008

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

WinForms - Editing Custom Readonly Collection In Property Grid

Feb 19, 2010

I have a custom collection, lets says COL, that derives from ObjectModel.Collection. I have my own collection editor that works fine when a property, of type COL, is Read and Write enabled. However, if I change the property to ReadOnly, the open editor button stops showing in the property grid. As a test, I override my custom editor with the CollectionEditor, and that worked fine. So, my question is, what check is the property grid making, that CollectionEditor passes but my collection editor fails?

View 2 Replies

Forms :: Delete Cookies In Winforms?

Nov 27, 2009

I've been trying to know how to delete all the cookies of a domain, created by using the WebBrowser control.I know that to invalidate a cookie, it's necesary to set its expiration date in a point of the past (a negative value), but all the information I found is for web developing aplications, and I'm using a form.

View 4 Replies

Forms :: Using Large Database In WinForms?

Dec 27, 2009

I am currently helping to write a Visual Basics program that was originally writing with access.The Original Access program has been used and modified over the past 5 years, During that time the database has gotten pretty big.The problem I am having is If I add the entire database to my data sources it creates data tables for every Table and Stored procedure even when they are not currently used in the program resulting in a 20+ minute build time just to debug.I am currently only adding Tables and Stored Procedures as i need them, so its not that much of a problem now, but as I continue to work and add tables the build time is going to go back up, and Id hate to have to wait 20+ minutes to test a small tweak I made.

View 1 Replies

Forms :: VS2010 WinForms Labels?

Nov 4, 2011

I have a label that displays text kinda like a title to something (autosize = falseTextAlignment = MiddleCenter) and whenever the label control isn't wide enough to display the single line of text it tries to auto-wrap it causing half of the text to be chopped off at the top and half of it chopped off at the bottom. I would rather it stay on a single line and cut the text off from the right

View 1 Replies

Have Forms In Sub-namespaces Of A WinForms Project?

Oct 15, 2010

If I create a new class library project in VB.NET, I can create subfolders (a la C#), add WinForm objects to these subfolders, and then specify a namespace:

Namespace Sub1.Sub2
Public Class SomeForm
Public Sub New()
InitializeComponent()

[code]...

This resolves as ProjectRootNamespace.Sub1.Sub2.SomeForm, which is good.However, if I create a new WinForms project in VB.NET, and attempt the same thing, I get this error in the designer:The class SomeForm can be designed, but is not the first class in the file. Visual Studio requires that designers use the first class in the file. Move the class code so that it is the first class in the file and try loading the designer again.Is there a way to have forms in sub-namespaces of a VB.NET WinForms app instead of in the root namespace?

View 1 Replies

Winforms - Friend Vs. Public For .net Forms?

Jan 19, 2010

Is it better to use friend or public forms in vb.net? What are the advantages of each?I notice when you import a vb6 project, the forms come in as friend, but when you add a new form in vb.net it is public. I have not seen any difference in the way they work, though, so I must be missing something.

View 3 Replies

Winforms - Passing Values Out Of Forms?

Sep 8, 2011

I have a very simple windows forms setup. Form1 has a progress bar and a button on it, when clicked the button opens Form2 which also has a button on it that launches Form3. On Form3 is a button which I want to use to raise an event back to Form1.To achieve this can I add an event handler on form1 that will listen for an event of the type raised in form3? Or do I have to pass references to form1 to form2 and then from form2 to form3?

View 1 Replies

Winforms - Unload All Open Forms ?

Feb 26, 2009

In the middle of converting VB6 code to VB.NET, I need to replace the following code that intends to close all open forms remaining in the application.

'close all sub forms
For i = My.Application.OpenForms.Count - 1 To 1 Step -1[code].....

I've replaced the Unload function with Close (as indicated by TFM), but the compiler complains that OpenForms is not a member of My.Application.Where can I access the open forms?

View 4 Replies

Forms :: VS2010 WinForms App Connect To Dll On Webserver?

Nov 13, 2011

I have a desktop WinForms app that I would like to be able to connect to my Sql Server database that I have through my GoDaddy webhost. Problem is not all ISP's forward the 1433 port (like mine) so I can't connect directly to the DB from any of my home computers without buying the expensive dedicated IP address package, which has me thinking since my website can connect directly to the DB I was wondering if it might be possible for me to make a dll that would have all of the database interaction through subs and functions and all my WinForms app would have to do is connect to that dll through http or something, anyone know if I could do something along those lines?

Reason for this is I would like other people to be able to connect to this database (the winforms app would have screens for creating and managing accounts, etc) without worrying about whether their ISP would block the DB port(s) it would just work.

View 5 Replies

Winforms - .net NUnit (2.5) Windows Forms Testing?

Oct 18, 2011

I am retrofitting unit testing into a fairly complex system designed and written by other developers in VB.net. I am trying to develop unit tests for the GUI forms using NUnit and the NUnit Forms extension. (I've been looking at c# examples that are fairly easy to port over if you have a solution but don't know VB syntax as long as it uses NUnit classes)

I will try and explain what I am doing but first a brief description of the program. It basically monitors server activity. You need to connect to a server via a modal form with IP and Port fields(amongst others). Once you have connected to a server other parts of the program unlock and become usable (such as configuration of the server).

Desired process: Load program > click connect button > modal connect form loads > enter details > click OK to connect > main form updates to logged-in state > other functionality

The problem is that I cannot test the functionality of the connect form and then the logged-in functionality of the program. I can test that it loads the modal connect form correctly; enters the details and clicks OK (all fine so-far) but it does not appear to logically progress the program. The modal form just closes again seemingly without running the connect code from the program back-end and I'm back at the main menu not logged in to anything.

I have a feeling that I've either missed something really obvious or that it's simply not doable in NUnit.I have trawled the internet in search of anything similar but the closest was another SO thread that was really generic. Without being able to actually test the logged-in version of the program, I'm at a major hurdle.Another issue is handling message boxes that don't have unique identifiers (e.g. "are you sure you want to exit?"); these also seem to be a major pain in the arse with NUnit (If it makes any difference, I'm running the tests as a stand-alone project using a reference to the executable file of the built project, not the actual source)

View 2 Replies

Winforms - Deploying A VB 2010 Win Forms Application

Nov 16, 2010

I am deploying a VB.net 2010 winforms application, and when I install it on the client's machine, the install process also installs an instance of SQL Server 2005 Express. The application connects to a central SQL database on the server. To install, I am using the "Publish" option in VS 2010. Why does it do that? There should be no need for a local instance of SQL Express. Is there a way to avoid installing SQL 2005 Express (I know it is free, but I would rather not have it installed if possible).

View 1 Replies

Winforms - NUnit (2.5) Windows Forms Testing ?

Jun 10, 2012

I am retrofitting unit testing into a fairly complex system designed and written by other developers in VB.net. I am trying to develop unit tests for the GUI forms using NUnit and the NUnit Forms extension. (I've been looking at c# examples that are fairly easy to port over if you have a solution but don't know VB syntax as long as it uses NUnit classes)I will try and explain what I am doing but first a brief description of the program. It basically monitors server activity. You need to connect to a server via a modal form with IP and Port fields(amongst others). Once you have connected to a server other parts of the program unlock and become usable (such as configuration of the server).Desired process: Load program > click connect button > modal connect form loads > enter details > click OK to connect > main form updates to logged-in state > other functionality

The problem is that I cannot test the functionality of the connect form and then the logged-in functionality of the program. I can test that it loads the modal connect form correctly; enters the details and clicks OK (all fine so-far) but it does not appear to logically progress the program. The modal form just closes again seemingly without running the connect code from the program back-end and I'm back at the main menu not logged in to anything. I have a feeling that I've either missed something really obvious or that it's simply not doable in NUnit. I have trawled the internet in search of anything similar but the closest was another SO thread that was really generic. Without being able to actually test the logged-in version of the program, I'm at a major hurdle.Another issue is handling message boxes that don't have unique identifiers (e.g. "are you sure you want to exit?"); these also seem to be a major pain in the arse with NUnit(If it makes any difference, I'm running the tests as a stand-alone project using a reference to the executable file of the built project, not the actual source)

View 1 Replies

Winforms - TextBox Validation In .NET And Windows Forms?

Mar 5, 2009

I'm using the following code to validate the text entered by user. It works perfectly fine. But I want to add the backspace feature so as to allow the user to delete the wrongly entered number.I have tried a couple of things and they worked but before last digit (after the decimal point) i.e. it does not allows to delete after the number has been completely entered.number is being entered in the format: 12313213.45

What shall I do?Private Sub TextBox5_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox5.KeyPress

[Code]...

View 7 Replies

Winforms - Word Wrap In Windows Forms (.net)?

Apr 25, 2009

how to do word wrap in drawstring in vb.net 2005.

View 2 Replies

Forms :: Create Separate Parts/winforms Of The Same Application?

Sep 19, 2011

is it a bad idea to create separate parts/winforms of the same application (using the same SQL Server DB) in different executable files. For example for a School IS: A Receptionist App, A Teacher App, A Principal App and so on.

View 2 Replies

Forms :: Run A Command Line Script From Within Winforms Application

Jul 19, 2010

I am writing an application in which a user is doing a file conversion. I have a set of tools that can perform the conversion on the fly via command line, but I'm not entirely sure of how to go about passing the parameters I need to the command line and running them. Can someone point me to the right direction?Would I just create a System.Diagnostics.Process and use that? If so how do I do the line by line command? For instance if I need to issue a cd command to change the directory and then execute a command after that how would I do that?

View 1 Replies

Winforms - Where And When Is InitializeComponent Called In Windows Forms Control

Jun 25, 2009

In C# Windows Forms, a user control's InitializeComponent is called from the form's/control's constructor. When I create same scenario in VB.NET I don't get a constructor, and I can't locate a place where InitializeComponent is called.I need to call my code between InitializeComponent and when the control's Load event is raised, preferably still in the control's constructor. How do I do this in VB.NET?

View 2 Replies

Replace Default Windows Cursor With A Custom Cursor (winforms)?

Feb 16, 2011

This VS010 solution is not providing my intended outcome as a custom override of a 'crosshair' or 'reticle' cursor e.Graphics.DrawPath() is the function that isn't working. This

WORKING solution demonstrates how it's supposed to work. The additonal PictureBox added to a Panel is, for reasons I don't understand, not allowing the 'new' cursor to appear.

Option Explicit On
Option Strict On
Imports System.Drawing

[Code]....

View 2 Replies







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