Forms :: Form Object Access From Class Method

Oct 22, 2009

I want a string and a listbox, both which are in a form to be modified by an instance of a class method. Should (could I):

1. Pass the entire form to the class method as parameter.

2. Pass the listbox and the string to the method as parameters.

What's the best approach to get access and modify this string and listbox on the form.

View 3 Replies


ADVERTISEMENT

Populate A List(Of Object) In A Class Method, Where The List Was Passed To The Method As A Parameter

Aug 13, 2011

I'm trying to code a class of RandomNumber. One of the class methods needs to populate a "List (Of RandomNumber)" ... which was passed as a parameter to the method ... with 10 random numbers between 1 and 50. DEAD SIMPLE :)

View 6 Replies

Get Name Of Class Without Instantiating Object Or Having A Static Method?

Feb 22, 2011

I hate to see the name of the class used as a string parameter like "FileDownloader" in the code, and I would like to use something like this FileDownloader.Name(), where FileDownloader is name of the class.Only problem is that I can't find out how to do that without instantiating object or creating a static method..Is there a way to get a class name in .net without having the object instance and without creating a static method that returns the name of the class?

View 4 Replies

Create A New Class That Inherits From The Base Form Class And Define A New() Method With Parameters?

Oct 1, 2008

I've been creating short test apps repeatedly to try to understand some of the concepts in VB.NET.For the most part it has been illuminating.I read Bucky's .NET knowlegebase tutorial on passing objects as parameters to newly created forms. He shows how to create a new class that inherits from the base form class and define a New() method with parameters Extending the concept I thought about doing the same thing with a form that was created at design-time (In this case Form2).

[Code]...

View 6 Replies

Access To Object Passed ByRef In The Constructor Of A Class Through Another Part Of The Class?

Aug 18, 2009

I have some classes, BsfciFile and StudyFlashCard. Bsfci is the extension to which I save my set of flashcards in an INI format. I am currently working to transform my code from using Windows API calls to access the INI to using a IniFile class that I found on the internet. I would like the BsfciFile to have a Array of StudyFlashCard objects, but I would like the StudyFlashCard class to use the IniFile class object contained in the BsfciFile class. I can pass the IniFile from the BsfciFile class to the constructor for the StudyFlashCard class, but I want it to modify the same IniFile as the BsfciFile class has later on.

[Code]...

View 1 Replies

How To Use BindingSource.Find Method Alongwith .Net Object Class

Mar 7, 2011

I want to search particular item in Binding Source for which i use BindingSource.Find() method, but it throws an exception "This operation requires an IBindingList". My binding source is bind to a .net class object.. I searched over the internet, but could not find the clear solution to achieve this task. The sample class code is given below:

Imports System.ComponentModel
Public Class Department
Private _code As Long

[Code].....

View 1 Replies

Access A Class Variable Inside Shared Method (JSON)

Jun 20, 2012

Inside my .aspx I have some JSON code that looks like this:

[Code]....

Basically what I'm doing is pulling text from two labels on one page, and sending them to another page by calling the "doIt" function which looks like this:

[Code]....

Just so I'm clear, the "doIt" function and the JSON call are on two separate web forms. My problem is that with the "doIt" function being Shared, I can't access any global variables of the class. And if I remove the Shared, my JSON doesn't execute.

View 1 Replies

Forms :: Way To Return Multiple Rows Of Data To Calling Method Via Class Property?

Jan 28, 2009

I have this application which has one class. I need to return a recordset of data to the calling form. If i use Properties to return, it can only return only a single value at a time. Right now i'm returning a datareader object with one of the properties.Can anyone suggest a better way to return multiple rows of data to the calling method via Class Property?

View 1 Replies

Strongly-typed Generic Method Invokes Its Argument's Base Class Method Instead Of A Shadowed Method In T?

Oct 19, 2010

Consider a MyForm class that contains a shadowed implementation of Show(). It also contains a CreateForm() method, which accepts an instance of the form and calls the shadowed sub:

[Code]....

View 3 Replies

Windows - Access The My.Application Object From A Form Or Control Object?

Jul 6, 2011

I have a solution with several Projects in it. There is a Windows App project (called ImportClient), and a Class Library (Import.Library). The Import.Library has functions to perform data imports (I have other applications in the solution that also need to call it). But the interactive application, I want to be able to pass in some form controls, and have it update the GUI. No problem. But, I also want to execute a DoEvents() so that the loop execution doesn't hang other interaction to the app.

So, ImportClient has a reference to Import.Library. But I can't add a reference to ImportClient to the Import.Library, because the compiler complains about circular reference, etc. I don't know how else to define the My.Application object of ImportClient as a parameter to the data function in ImportLibrary.

(I realize this is a dumb question - problem is, for this project I have a tight timeline, and haven't learned how to do the BackgroundWorker process. If you think I could pick it up quickly, I'm open to some hints about how to update the progress bar on the GUI, and how to pause / cancel the background task.)

View 1 Replies

Object Passed ByRef To Form, But Not Accessible Throughout Form Class

Feb 18, 2010

Hi

I've got a pretty general question about the best practice in passing an object reference to a Form in VB.NET. My form is a dialog and I've created an overload ShowDialog method, where I pass an Object into it ByRef.

The trouble is, I want to be able to refer to that Object throughout my dialog Class and not just in the ShowDialog method. For instance, some of my Events for controls on the form, need to reference that object.

I know I could create a local Private variable in the Class and assign it to the passed value, and then use that value. However I'm thinking this isn't very efficient because it would (I believe) create a new copy of the Object (which is a complex, large class in itself).

View 8 Replies

Object-Orientation - Implement The Class And Access The Database For Values?

Dec 17, 2009

I've now properly started implementing OO into my system (which I probably should have done from the start) but I just want to clear some best practices.So let's say I have a class called Job which contains information such as Description, Project Manager (Employee class), Value etc. at the moment, if I initialise the Job class it will initialise all the information held within it, even if I only want the job description. Is it best practice to do this or is it better to implement the class and access the database for values as and when they're needed? Or is it just better in those cases to just access the database directly?

View 1 Replies

Class - Call A Method In The Default Instance Form Instead Of Instantiating Another?

Nov 15, 2009

When an instantiated class calls a method in the parent form class, VB.NET starts a new instance of the form class instead of calling the method on to the active one.How do I tell it that I have just one instance of my form class, or that I don't want to create a new instance of the form and just call the method on the already active form?

View 2 Replies

Winforms - Calling A Method From Different Class To Write Text On A Form?

Dec 5, 2011

I have two forms Form1 and Form 2. I am passing a function with three values from Form1 and want the load event of form2 to trigger this function.. Basically I want to "paint" the values of qseq, midline and hseq on form2

Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

[Code].....

When I run this, nothing gets printed on form2 as when load event is triggered thee drawstring method is not called. how can I call drawstring from load method as drawstring takes in arguments and is called from Form1 class.

View 1 Replies

Forms - Error: Cannot Access Disposed Object

Mar 20, 2010

I got the "infamous" 'Cannot Access Disposed Object.' error when I was attempting to open a form again after I had closed it. The fix (even though it's annoying), is easy enough; but again it's managed code problems and weirdness I still haven't changed my opinion that I won't be using MS .NET after this when I get my development box back to normal. BUT anyway the solution is self explanatory and very easy (and somewhat obvious) [Code]

the Application hiccups with a very nice message, after you close the form down and try to reopen it, that says: Cannot access Disposed object. So, my thought is that the "IsDisposed" property runs some sort of function to determine the Garbage Collection state and does a collection, or updates the request for the collection to be done.

View 12 Replies

Forms :: How To Let Method Know Which Form Is Getting It's Buttons Pushed

Jan 21, 2010

In design mode, I have 2 forms, Main and Profile. Both have many controls on them.When executed, the Profile form is duplicated 4 times and named Profile1 through 4. Among the controls on these forms are 3 buttons that copy the selections from the other 3 forms to the one that had the button pressed.How do I accomplish this? I don't understand how to let the method know which form is getting it's buttons pushed so it knows what form to copy...

View 2 Replies

Deep Clone Of Object With Base Class System.Windows.Forms.Control

Apr 18, 2012

I have an object (a third component gridview) which is serializable, and I need a deep clone of this object. I have the following code which throws the exception."The type System.Windows.Forms.Control in assembly System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKey Token=b77a5c5 61934e089 is not serializable".So the gridview's base class is System.Windows.Forms.Control, which is not serializable. How can I get a deep clone from the gridview? [code]

View 5 Replies

Forms :: Focus() Method Fails With Second Show Form?

Feb 7, 2010

I have a simple login field, which works fine with the exception of one quirk. The form is set up with the tab order to go to the UserID first and the Password text box second. This works fine when the form is used the first time, but when the form is used the second time the focus in placed in the Password field. If the form is used a third time, focus is moved the OK button, that is each time moves to the next tab order. I even tried to set the focus in the Load event as in Me.txtUserID.Focus(), but this doesn't change the behavior. Again, I should note that I close the form and not hide the form.

View 3 Replies

Forms :: Mdi Call Active Child Form Method?

Aug 20, 2009

I'm trying to call a method defined within a child form from the menu strip of the parent form when the child form is active.

View 1 Replies

Declaring A Object - Instance Of An Object To Be Created When A Form Loads Or Another Class Is Created

Oct 5, 2009

If you want a instance of an object to be created when a form loads or another class is created, you have two options:

Public class example

private IAmAObject As IAmAObject

public sub new()

[CODE]...

Or like this:

public class example

private IAmAObject as new IAmAObject

public sub new()

[CODE]...

I always use the first one. It's more type work but I think it's neater. How about you people and is there any real difference between the two?

View 4 Replies

Access Enty Point Method Of Form Based Applications?

Mar 13, 2010

How can I Access the Enty point method of Form Based Applications?How can I set their attributes?

View 2 Replies

Threading - Access A Value Of A Control Within A Form Outside Of The Form Class

Jun 3, 2009

What is the best way to access a value of a control within a form outside of the form class. I have a lot of functions defined in a module, one of these functions requires a series of values from controls in my main form such as the FolderBrowserDialog.SelectedPath element. I understand that these cannot be accessed in the format form.FolderBrowserDialog1.SelectedPath and that they need to be accessed using a delegate. This is the part I am stuck with.

[Code]...

View 3 Replies

Form Application .NET File.Create Method, Access Denied To Path

Sep 25, 2011

I wrote an application which parses a website and downloads an mp4 file from website. User can select the path where he wants to download the video. When I try to download I get an exception for the file, Access Denied to Path. When I gave the permissions to folder that I chose, then works fine. How can I resolve that problem? End-User will select the folder. How do I change the permissions?

View 1 Replies

How To Pass Form Object To Data Class For Update

Mar 11, 2009

I am converting some VB6 code which passed an unknown form object to a class, which then used the passed form object to reference the calling form and direct the data from the class as follows:
The Called Class in the class clsGetRecord
Public Function Execute(ByRef FRMForm as form) as booleanFRMForm.List1.Additem(SomeData)....Execute = SomeBool End Function
The clsGetRecord is used by many different forms which receive data all have objects called List1 as: The Calling Form for the form
frmThisFormPrivate function() as booleanDim objRecord as new clsGetRecordbRet = objRecord.Execute(frmThisForm)
The passed form object which will receive dataEnd function. Is there any simple way to do this since the calling form object is unknown at design time?

View 2 Replies

Get The Name Of Parent Method/class/file Name Inside Other Method Call?

Feb 16, 2010

I will try to explain what I need.Let's say that I have a class like this:

Public Class Example1 Public Sub ToBeCalled()

[Code]...

View 5 Replies

Utilizing A Centralized Class object That Needs To Call Another Class Object?

Jun 7, 2010

I am utilizing a centralized class object that needs to call another class object. The program itself will do something like the following

sFieldValue = CentralObject.ObjectHandler(1, TestFunction, "FunctionVar,FunctionVar2,FunctionVar3")

In the central object I have a function

Public
Function ObjectHandler(ByVal ObjectType
As
Integer,

[code]....

View 5 Replies

Flattening An Object Hierarchy Using A Shim Class - Initializing Derived Object Properties From The Base Object?

Jul 10, 2010

I am somewhat new to object oriented programming and am attempting to flatten a Linq object hierarchy by using a shim class.how to initalize a derived class with property values from a base class?I have two objects, a base object with about 100 properties, and a derived object which inherits from the base object and adds a few additional properties beyond those of the base object. My simple constructor creates the derived object, but I am looking for a way to initialize the derived object properties with values from the base object.Right now I am using reflection to iterate over the properties individually and I suspect there may be a better way. The following example shows my shim class constructor for the derived class, and two properties:

newProperty1 - a new string property of the derived class

flattenedProperty2 - a new string property of the derived class, copied from a 2nd-level object of the base class

Code example:

Public Class derivedObj
Inherits baseObj
Private _newProperty1 As String[code].......

Is this the correct constructor approach to flatten the object hierarchy using a shim class? My second question relates to initialization of properties in the derived class. The constructor above creates the derived object, but what is the best way to initialize the derived object properties with values from the base object? The following code uses reflection to iterate over the properties individually, but I suspect there may be a better way.

Code example:

' property names are in the string array fieldNames

'baseObjQuery is an ienumerable of baseObj

'derivedObjList is a list of derivedObj[code].....

Is there a simple way to initialize values for the properties in the derived object based upon the values of the common properties in the base object?

View 7 Replies

Access A Object From A Different Form?

Mar 31, 2009

I have 9 different classes, and 9 buttons. Each button needs to call the messagebox.show(") from each class separately

View 4 Replies

Forms :: Running Form In Class Library?

Jun 20, 2012

i have a query iam able to add items in listbox from form 2 to form1 from windows application in vb.net but iam unable to add items in listbox from form 2 to form1

View 3 Replies

Forms :: VB With Implementing A Class In Form Code?

May 8, 2009

I am having trouble with this project I am working on. I am a beginner to vb and have some background in access databases. I will attach my am doing an inventory project. When you execute the form, a main form pops up that allows you to choose Production or Inventory. My issue is with the Production. In the production form that pops up after clicking Production, there are text boxes to be filled out by the user based on the production run.plementing a class that will give the box count based on the box type entered. I have to use a class based on the project requirements.

Basically to calculate the usage, enter in a random number for Pods Produced, then enter in a box type (which is A box, B box, C box, D box, Master Case). I want the Public Class Box Count in the code to be able to be placed in the production form's main class code and calculate the box count based on the box type entered. If A box, box count should be 50. If B Box, box count should be 100, If any other box is typed in, the box count should be 150

View 4 Replies







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