C# - Respond To Events From A List Of Class Instances?

Jan 21, 2011

I have a .NET class, InstrumentConnector, that has an event, StatusChanged. I want to create several instances of this class (each class handles a separate file) and respond when the StatusChanged event is raised any instance. How would I do this in .NET? Do I want to create a List(Of InstrumentConnector) or a similar IEnumerable? How do I write the event handler to respond to a particular instance's StatusChanged event?

Here is the InstrumentConnector class and the module with the StatusChanged handler:

Public Class InstrumentConnector
Private _inProcessDir As String
Private _doneDir As String

[Code].....

View 2 Replies


ADVERTISEMENT

VS 2010 Sorting A Listbox (after Trying To Copy Class Instances Properties To A Temp List)

Jan 25, 2012

I'm trying to figure out a way to sort the entries of a listbox... but in a different way instead of the obvious one (sorted property). First of all, I need to explain how the items are populated at first:

[Code]...

View 19 Replies

How To Respond To Msgboxresult Events

Jan 13, 2011

I have a datagrid and I want to delete selected row from that grid. It is working fine upto this. but I want to add some advance functioning with msgbox YES-No buttons. If user select some row and click on delete button, A msgbox with YES/No options appears. If user clicks YES, row should be deleted but if No is clicked then that row should not be deleted.I have tried it many ways,

Below is the code:
Private Sub btnDeleteSitting_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDeleteSitting.Click

[code]....

View 1 Replies

How To Get Buttons On Form To Respond To Key Events

Nov 23, 2010

How can I make buttons on a form to respond to keypress, keyup and keydown event?

View 3 Replies

Make More Than One Control Respond To Mouse Events?

Jun 27, 2012

I have some code in a label's mousemove event that allows it to be dragged around my form while the left button is held down. While this is happening none of the other controls on the form respond to their own mousemove events as the mouse pointer passes over them. Is it possible to make more than one control respond to mousemove events at the same time?

View 6 Replies

Mouse Events And User Control - Control Won't Respond To The Events

Dec 31, 2010

I created a control that has picture box control docked within it. This control allows me to "animate" the image by swapping them out by setting the interval to swap them at. I want to use this control kind of like an animated icon within a application, but because the picture box is docked, the control I created won't respond to the events, MouseHover specifically. [Code]

View 2 Replies

C# - Respond To Descendent Class PropertyChanged Event?

Mar 10, 2011

I have a class, BaseSample, that uses another class, MainData, as one of its fields:

Protected _sampleData As MainData
Public Property SampleData() As MainData
Get

[code]....

MainData in turn has a collection of a class, ProcessData, as a field and ProcessData has a collection of a class, Measurement, as a field. I.e.:

MainData
|- IEnumerable (Of ProcessData)
|- IEnumerable (Of Measurement)

These classes are entities in a LINQ to SQL file. In the Measurement class, I raise the PropertyChanged event when the CrucibleOxidizedMass property changes:

Private Sub OnCrucibleOxidizedMassChanged()
RaiseEvent PropertyChanged(Me, New ComponentModel.PropertyChangedEventArgs("CrucibleOxidizedMass"))
End Sub

In the BaseSample class, I want to respond to the CrucibleOxidizedMass PropertyChanged event in any of the descendent Measurment instances. How would I do this?

View 1 Replies

VS 2008 Controlling Events From Multiple Program Instances?

Mar 20, 2010

I'm having a lot of trouble finding a solution to my problem, and its probably because I don't know exactly how to ask the right question - can anyone here point me in the right direction?

View 3 Replies

Defining A Class For Multiple Child Class Instances?

Feb 10, 2011

I have created a class for a Sports Facility. A facility has a Name, Status, Notes, etc as members of the class. This works well, I can create a new instance of an exisitng Sports Facility from the database, create a new instance, etc. All working well.What I am stuck on is accessing a list of Sports Facilities. I know I can create a new list by doing

Dim List As New List(Of Facility)

For Each fRow As DataRow In ds.Tables("Facilities").Rows

List.Add(New Facility(fRow.Item("FacilityID"))

Next

View 4 Replies

Multiple Instances Of Class?

Mar 29, 2010

I have the following problem. (VB.Net 2008)I have created a class (myFirstClass). In this class there are a lot of calculations being made wich gets fired by events in that same class.Now i want that same class to be able to fire more instances of itself. However i noticed that each time i fire an event from a Sub the program waits till the event is finished before going to the next line of code. This is a problem since i want the event wich fires a new instance of the class to fire it and forget about it.

View 7 Replies

.net - Allow Math To Occur On Instances Of Class?

Nov 27, 2010

Is there some interface I can implement to allow basic comparisons and math to happen as it would an integer?

For example, let's say I have the following class:

Public Class Something
Public SomeBigNumber as UInt64
End Class

I would like to do something like this:

Dim SomethingA, SomethingB, SomethingC as New Something
....
If (SomethingA-SomethingB) > SomethingC Then
'Do stuff
End If

I was hoping to be able to implement some interface (if that is even the right term for it) that would return the UInt64 contained in the class for comparison and math, if possible.

View 1 Replies

Added To Each UserControl (different Instances Of The Same Class), A Little Map?

Apr 28, 2009

I have a form whose purpose is to let the user to load map files.The form may manage a variable classes of maps, and each class have his own UserControl.To make it more user friendly, I added to each UserControl (different instances of the same class), a little map, showing a small picture of the map, and some data, as bound coordinates.

The problem is, that it looks really ugly. The maps are so big, compared with the rest of the UserControl (who contains just a button and a textbox to search for files).I wish to fix it, but I din not see an elegant way to include the pictures and info.I attach a form screen capture with two UserControl.I would like to get some tips for more experienced users. There are some guidelines?

View 5 Replies

Creating Instances Of Own Class At Runtime?

Sep 3, 2011

info on creating instances of my own class at runtime. Simple project for family recipes but would like the option to add new recipes with new instances of my own food Item class at runtime. Creating my own class,no problem. Storing the data in an XML file, OK on that as well. My issue is creating new instances of different food item class as I use this program over time

View 13 Replies

Multiple Instances Of A Custom Class?

Feb 15, 2009

I have a sub that runs on a button click which I want to create a new instance of a custom class and add it to a list of already created instances of this class. I want the result to be a List Of collection of all of my class instances.

My problem is that each time I run the sub, it simply 'overwrites' the first instance of the class and adds a copy of it to the list instead of writing a new instance. My code is along these lines

dim objFixture as new clsFixture
For n As Integer = 1 To intNoOfChannels
objFixture.SetChannelAddress(n, intCurrentChannelTotal + 1)
intCurrentChannelTotal += 1
next
lstFixtures.Add(objFixture)

View 7 Replies

Passing Variables Between Instances Of A Class

Jun 17, 2009

I created a program a while back, in the traditional VB.NET way by drawing a bunch of forms. I have started playing around with creating the forms at runtime using classes. I have a placeholder form called frmStartup which merely calls the CreateLogin() sub from the CreateFormClass. The CreateLogin() sub creates a new blank form, then calls the grpbxLogin(), btnSave() and btnExit() subs from the FormElementClass which adds all the buttons and textboxes to the form. Within the FormElementClass, I have associated btnSave and btnExit with event handlers. These even handlers call subs from the DataProcessingClass. The event handler for Exit works just fine.I am having a problem with the Save event handler. Precisely, I don't know how to pass either the username or password from the Login form to the btnLogin_Click() sub in the DataProcessingForm. I have tried using Me. and frmLogin., but the program doesn't see either of those. If the Login form is an instance that is disposed of once another Sub is called, then it won't exist later on to call from. I have tried declaring variables and passing those along to btnLogin_Click, but no matter where I put it, the program doesn't see txtbxUsername.Text or txtbxPassword.Text. Not even from within FormElementsClass, which is were the boxes are created.Any ideas on how to pass variables in this case? I am not even sure what you would call this such as passing between classes, or passing between instances.[code]

View 9 Replies

Repor Declaring Class Instances?

Oct 20, 2008

I've decided to forget the d@mned custom code because everything I do with comes up with errors I don't know how to fix and it seems no one else does either. Or they do and they're keeping to themselves.

I put the functions that I needed to use in a class called MsgBoxOperations. The file name is MsgBoxOperations.vb In the report, up on the standard bar where file, edit, view, and all the other stuff is, is one that says report. You click that and go to report properties and it brings up where you can name the report and put in custom code...(hate custom code right now...) and where you can put references and class instances. Clicking on the Reference tab brings up wher you put in your references and classes.

In the classes area it asks for the Class Name, which I put in MsgBoxOperations, and the instance name of that class, this case mbo. I get that far and put in those two things and save it. Then I go to the textboxes where the values need to be. I put in the text box: =Code.mbo.GetStartDate

I've already tried taking the Code. part out and it screams that mbo isn't declared. So it does have to be there. I go to run the code and comes up with this error: QuoteError in class instance declaration for class MsgBoxOperations: [BC30002] Type 'MsgBoxOperations' is not defined.

I've posted before and still have received no help or someone tried to help but then stopped when their suggestion failed and then no one else wanted to help. I've googled this problem to the point where every link that it comes up with I have already clicked and found their information useless. I've got a freaking migraine because of this issue and have been in tears over it more than once.

View 14 Replies

Alphabetize An Array Of Objects That Are Instances Of A Class?

Nov 1, 2011

I have an array of objects 2000 that are instances of a class. I want to alphebatise these objects by a detail of the class.

View 1 Replies

Creating Instances Of A Class That Has Several Readonly Properties?

May 24, 2011

What is an elegant way to create and initialise instances of a class that has several readonly properties? Passing all values in a constructor would not be very convenient.

The purpose is that instances are immutable after initialisation. However if the constructor is not used for initialising all the property values, then how can the readonly properties be changed from another class?

View 2 Replies

VS 2010 'Infinite' Public Instances Of A Class?

Jan 24, 2012

I'm a little out of my comfort zone here having programmed in VB6 quite a few years ago things have changed a lot since then.My issue is I have a class that I've built which works with no issues but I would like to be able to keep a 'handle' of some description on this class so I can also make adjustments to it's parameters when the user changes something. My problem is that I need to do this for an unknown quantity of these class instances.

In the VB.Net language how would I create an instance of this class that could be accessed by any Sub within the application and each instance created can be individually accessed by specifying some sort of identifier?

View 2 Replies

Creating An Array Of Instances Where Instance Could Be Base Or Sub Class?

Oct 31, 2011

I have a class structure and am attempting to create an array of object instances from the class some instances are parents and some are children Code snippets,

Parent Class object
Option Strict On
Option Explicit On
Public Class cTransportItem

[code]....

View 1 Replies

Ensure Instances Of Class Finish Before Main Terminates?

Feb 14, 2012

I have a MultiThreading issue and conceptual question using Visual Basic (but it applies to almost all languages). [code]...

View 2 Replies

List Available Sql Server Instances (default & Named)

Oct 6, 2008

I would like to get a list of sql server instances on a computer but need both default and named instances.In the post: [URL] the code works perfectly for finding the default instance of SQL Server but it doesn't show other running instances (named instances). On my development computer, SQL Server Express, SQL Server 2005 (both named instances) and SQL Server 2008 (default) are all running but express and 2005 don't appear in the combobox dropdown list.

View 3 Replies

Reflection Instances To Get A List Of Applications Running

Jun 18, 2009

I have created a simple windows forms application. I would like to be able to connect to that running application and view certain properties from a seperate windows form application. In VB6 I would have run the first application and then called GetObject to connect to the instance. Does anybody know how I could do this in .Net. I'm guessing I'd have to use reflection to get a list of applications running and then somehow connect to them but I'm not sure how to do this?

View 5 Replies

MovablePictureBox - Set The Flags In All Other Existing Instances Of The Class, When It Is Set To True In The Selected PictureBox?

Apr 17, 2010

if I have several of these movable PictureBoxes added to a Form (Form1) and want to display a selection rectangle only on that PictureBox, that is just selected,then I think I should use a flag to mark whether a PictureBox is selected or not. The flag could be used in paint event to decide,whether the selection rectangle is to be drawn or no .To add a flag property to the new class is no problem. But how can I set the flags in all other existing instances of the class, when it is set to True in the selected PictureBox?

View 1 Replies

Object Oreinted Random Failure - Define Two Instances Of Class And Configure ?

Oct 27, 2009

I am having a problem with a and OOP class i made that contains a sub that creates random integers.

Problem is if i define two instances of this class and configure them(name in this case) then they both display different names but the random integers are ALWAY the same. in this case having the integers the same kinda kills the idea of the program.

Is it possible that the random part only every works for one class, but if .NET is fully OOP then this should not be possible... right?

Some of my Code (broken down to something smaller) i will display for obvious reasons.

Code:

View 11 Replies

Class Library Events?

Mar 6, 2012

I`ve made a .NET component in C#. After that, i`ve created a class library in VB.NET and added this C# component and a couple of buttons to the library (creating another component now with buttons). So far, so good.The problem is: when i use this final component (vb.net class library), i want to link all MouseClick Events of its own components (buttons and C# component). In other words, when i add this final class library to my VB solution, it has its own MouseClick event. But when i click inside it doesnt raise the click event unless i do not click in the buttons or in the C# component inside it. I want to raise this event in the application wherever i click (inside or outside its own components).

View 14 Replies

Create Events For Class?

Feb 25, 2010

how to create custom events. If anyone can give me some simple sample code and/or refences,

View 5 Replies

Handle Events In Another Class

Sep 2, 2011

I'm trying to move some code into some class files to clean up my code. One area I'm having trouble with is reporting progress for events between the object performing the task and a progress bar. I guess the event functions have to be placed in the new class but they also need to update the progress bar on the calling form? Can the classobject return updates in place of the event handlers?

[Code]...

View 2 Replies

Public Class Events Not Seen Outside

Mar 3, 2009

I've got an issue where Public Events in a class aren't being seen outside the class.
Code looks like this:
Public Class Class1
Public Event Event1(someargs as object)
Public Sub New()
'Perform Some Code
RaiseEvent Event1(someargs)
End Sub
End Class

View 1 Replies

Raising .net Events From Another Class?

Aug 15, 2011

can I call shared events contained in one class from another class?

for example:

logonclass.vb : handles login logic and authenticates against database
logonmanager.vb: hold current user reference and some logon and timeout events
Logon.vb: A form with a submit button.

I would like to do something like this but I can't get the compiler to agree with it

If VerifyEntries() Then
Try
privLvl = LoginClass.AttemptLogin(txtUserName.Text, txtPassword.Text)[code].....

If this isn't the proper way to wire things together let me know so I can learn to structure differently. In my planning it seemed like I was raising a lot of extra duplicate events from my logonclass to my loginmanager class. Then the loginmanager had to raise it again for the main form to see the change event. It got me thinking that if I publicly shared the events and could raise them from wherever then it would cut down on the amount of events I needed in code and the amount of them flying around at runtime.

View 2 Replies







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