Event Won't Come Through Class Hierarchy

Feb 2, 2010

I'm writing a Windows Forms application in VB.Net 2008, .NET Framework 3.5, and I am trying to handle an event created by a class that get's instantiated several times throughout the program. The thing is the events gets fired in the Functions class, but nothing's happening in the main class.I tried to change the called class by instantiating it in the beginning of the main class, by using 'WithEvents testEvent as MTO_Tool.Functions = New Functions' but that also didn't work.

Code:

' The main class:
Public Class MainScreen
WithEvents testEvent As MTO_tool.Functions
Private Sub test() Handles testEvent.SaveChanges

[code]....

View 1 Replies


ADVERTISEMENT

Class Hierarchy - Data Design In An RPG Game

Aug 10, 2010

how to organize the classes within my RPG project that I'm making. I've tried to implement a battle system but I am not comfortable with my initial results. This is the basic layout I currently have for my classes. [Code] clsCharacter contains statistics pertaining to one character, including magic available to that character to use. Also includes what weapons that character has equipped. clsTeam contains multiple clsCharacter, as well as a list of items that each clsCharacter in the team can use. clsBattle contains two clsTeams. One team is the player and the other is the computer. Now, this is a wonderful way to organize data. However, I see limitations with this approach. For instance, to pass data from Battle to Character, it has to pass through the team class and vice-versa. Plus, if I use Properties, it transfers data as ByVal instead of ByRef, so I cannot guarantee that I'm editing the original and not a copy of the passed object (IIRC)

In addition, I feel it is just messy code to include methods within the clsCharacter class that invoke this: MyTeam.MyBattle.DoAction(). Plus, the clsCharacter might not even be in the battle at the time - I don't won't to bog down that class featuring code that is exclusive for battling when I also need to be concerned about moving around the map, saving/loading data, etc. So, any suggestions? Right now, I'm burnt out of ideas. One idea I have so far is to include a function for the clsCharacter that exports a list of all possible moves the character could make, and if the character is CPU choose the most optimal one, and if Human than wrap it up in some nifty GUI so they can choose what action to take. But at the same time, how do I use that information within the context of the battle?

View 2 Replies

Inheritance Hierarchy For Class Quadrilateral / Square And Rectangle

Sep 30, 2009

I have to write an inheritance hierarchy for class Quadrilateral, square and rectangle. Use Quadrilateral as base class of the hierarchy.

So for I had this:
Public MustInherit Class Quadrilateral
Public Function getName() As String
Return "Shape"
End Function

View 1 Replies

Class Hierarchy - Data Design In A RPG Game Where Classes Overlap?

Aug 19, 2010

This is a followup to the question I asked here:

[URL]

I understand the answer in the post above, which is absolutely amazing, by the way. It's about implementing interfaces with a class. However, what if a class needs to share features with another class?Yes, that class can an Interface. However, let's use this sample definition.

[code]...

Or, in other words:An equippable item can perform acts outside of its typical usage of a shield or weapon. But not all items can act as a sheid or weapon.I mean, I could create a class that implements IWeapon, IShield, IMagic, IUseableItem, etc. But there should be a better way than returning NULL when those interfaces are called.

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

Raise Event In One Class And Handle The Event In Another Class?

Dec 27, 2010

Is it possible to raise event in one class and handle the event in another class? If so, how?

View 6 Replies

Any Event Built In The Class That Is Fired Automatically When A Class Is Deserialized And Ready To Be Used?

Nov 18, 2010

I have a class that is stored after serialization and compression.Is there any event built in the class that is fired automatically when a class is deserialized and ready to be used??

View 1 Replies

Handle An Event Raised In Class Inside Own Class?

Apr 14, 2009

I have a "partial" class in VB.NET. Half of it is auto generated by a code generation tool. That half implements INotifyPropertyChanged, so any properties in that part of the partial class raise the PropertyChanged event.In my "custom" part of the class, I declare another property that depends on one of the properties in the auto-generated side. Therefore, when that auto-generated property changes, I also want to raise a PropertyChanged event on my custom property that depends on it.

If I go into the generated part of the class and raise the event there, that will get overwritten if I ever re-generate that part, so I don't want to do that. I would rather add an event handler in my side of the partial class that checks if the generated property changed, and if so, raise another event for my custom property.

[Code]...

I'm assuming it's because normally you'd use the WithEvents keyword to tell the compiler that you're subscribing to events from that object. I don't have a clue how to do this inside of the class that's actually raising the event, or if that's even possible.

View 1 Replies

How To Program The Hierarchy Like This In .Net

Mar 30, 2011

I am a beginner for using VB.NET. I have a problem in which we have several "Program", each "Program" has N "group", and each group has N "unit", shown as follows. i need to link "Program" and the corresponding "group" and "unit" together. First , the properties of lower layer depends on upper layer's properties. Second, If i delete one "Program", the cooresponding "group" and "unit" will be deleted as well.

[Code]...

View 2 Replies

How To Save Object Hierarchy

May 5, 2010

I have created a set of classes that represent an hierarchySo when I reference like this:

Dim alldeals as deals
alldeals.Deal(5).DealSlot(3).SlotType= "SomeType"
alldeals.Deal(5).DealSlot(4).SlotType= "SomeOtherType"

[code].....

View 3 Replies

Making A Shape Hierarchy?

Apr 10, 2012

I am working through my Visual Basic Book 2010 book and came across this Program example:Create 3 classes that inherit from a base class named Shape. The Shape class has an instance variable that is the name of the shape and also a CalcArea() function that must be overridden by each subclass. You will need to create the following 3 classes and use the formulas provided to calculate the areas.

Square � Area = sideLength * sideLength
Circle � Area = pi * radius * radius (use Math.Pi for the value of pi)
Triangle � Area = � * base * height

Each subclass should have a constructor that you use to set the name and the attributes required to calculate the area with. Each subclass should also override the CalcArea() function that is provided in the base class Shape. They will also need to implement the toString() method that will print out the shape name, any attributes (ex: sideLength), and the area.It also includes the Shape base class. You will need to add the 3 subclasses and add the appropriate code.

View 5 Replies

Object Hierarchy For Charting?

Jan 27, 2009

I'm looking for advice to make my code efficient in terms of execution speed and memory usage. Basically, how to lay out my objects. The program displays parts of several data series in bar- or line- charts, as well as calculated series based on these data series. The key user input will be to change what part of data series to look at, and that input should trigger instant chart update, with minimal lag.

[Code]...

View 10 Replies

Getting All The Parent Hierarchy Until Reaching A Certain Type?

Feb 3, 2009

I could put a Textbox in a Panel then that panel is placed in a TabPage, how do I go out going through the hierarchy of the Textbox parent until reaching the TabPage? My purpose for this is if I want to focus on a Textbox then of course I would have to also select the TabPage where it is located, is there an easier way than what I am planning to do?

View 3 Replies

Regular Expression: List Hierarchy?

Jan 6, 2010

I am working on an opening search screen for a program that grabs information on a file for the user. Subfolders are defined by periods so some possible files include

FolderA.SubFolder1.SetupX.txt
FolderB.SubFolder2.SetupY.txt
FolderB.SetupX.txt
FolderA.SubFolder1.SetupZ.txt

When the search button is clicked all of these are populated into a list box currently using the following function's

[Code]...

The problem is that subfolders will continue to be created with unknown names. I'm thinking I need to use some sort of loop that counts the number of periods and then compares the directories using some sort of negative lookahead to group them. Im still unsure how I'll make it so Clicking Setup Y and hitting OK will be able to maintain that I am opening FolderB.Subfolder2.SetupY.txt and not just SetupY.txt

View 4 Replies

Want To Eliminate One Level In Object Hierarchy?

Jun 7, 2010

Not sure how to do thisI have a hierarchy:

Deals at the top
Deals is a collection of Deal
Deal is a collecton of DealSlots

[code]....

View 3 Replies

Show Folders / Files Hierarchy In TreeView

Mar 5, 2008

Any code snippet they could post that will take a specified folder & show the files & subfolders hierarchy in a TreeView?

View 11 Replies

C# - LINQ To SQL To Query Parent And Count Childs In Hierarchy?

Dec 8, 2010

I'd take both C# and VB.NET suggestion.I'm using LINQ to query data. I'm trying to query the parent and count the child tags.Here's my Tags table column:

TagId (int primary)
TagName
ParentId (int Allow NULL referred to TagId column)

Here's some sample data:

[Code]...

View 3 Replies

Entity Framework 4.2 Table Per Hierarchy Group By Discriminator?

Dec 7, 2011

I am working on a project using an EF 4.2 code first model. This model contains a TPH inheritance structure for products. I need to group the polymorphic results of this inheritance model on the discriminator and am running into some issues.

The entity framework does not expose the discriminator to complete this grouping. My first question is can I get direct access to this discriminator? My reading and experience is telling me no, so I came up with this solution that sort of works. It is not performing well and I am not happy with how it will need to be maintained.

My classes look something like this (simplified):

Public MustInherit Class Product
<key()>
Public Property ProductID as integer

[Code].....

Also, this can give me easy access to shared properties (Name) but now I don't have many options to cast these into their real type, maybe a select case around TypeName.

View 1 Replies

Visual Studio 2010 - Creating Hierarchy Of Files?

May 23, 2012

I'm trying to create heirarchy of classes in vb.net. I was able to achieve it in csharp by using the following tags in .csproj

<Compile Include="ClassA.cs">
<DependentUpon>ClassB.cs</DependentUpon>
</Compile>

Below snippet in the solution explorer would be as follows

I need to achieve the same in vb.net.

I'm new to vb.net. Can anybody tell me the alternative of <DependUpon> attribute used in .csproj equivalent in .vbproj. For some reason, this attribute seems to be ignored in the .vbproj even though it is displayed in the visualstudio2010 intellisence.

View 2 Replies

IDE :: IntelliSense Slow When List Filtering Large DataSet Hierarchy

Nov 21, 2007

I just converted my project from VS 2005 to 2008 and started getting really bad lag only when intellisense iterates my dataset objects. The cpu maxes out one of my cores for about 2-3 seconds each time the intellisense list pops up. Is this a new feature of the 2008 ide?

View 19 Replies

Event Handling In Another Class?

Dec 1, 2011

I have an event defined and firing in class B

Public myEvent()

In class A:

Private WithEvents _b as B
Private Sub hander() Handles _b.myEvent

but, this handler does not get called.

View 1 Replies

Invoke Event Of Class From Another?

Jul 17, 2011

I am new to making events and I have read up on them to further my understanding of them, and I have come across a situation that I am stuck at. Currently I have a handful of classes (lets call them a childform) that are all inherited from a class that's a form (lets call it a parentform) with an event called UpdateData(). When these forms are created they are added into a hashtable of ParentForms then added into another form. I call on these forms through a method that returns the form from the hastable. [code]....

View 2 Replies

Raise An Event From A Class?

Mar 11, 2009

I'm trying to raise an event from a class. It looks ok but it did not raise the event as expected...?

Steps
1 - Load the form2

2 - Boutton1 call the form1 and load the class animation

3 - Class animation raise the event for the form1

Here is the code !

Public Class Form1
Private WithEvents AnimationTextChange As Animation
Public Sub mdiMainEvent_StatusTextChange(ByVal _text As String) Handles

[Code]....

View 3 Replies

Raise Event From Sub Class?

Sep 6, 2009

I have 2 classes one main class called Mygrid and another class inside it called TLBoxEditingControl which inherits a textbox into grid cell.Also I have added one Listbox called LstBox to the usercontrol MyGrid.

1) Initially its visible is false. How can i make visible true in TLBoxEditingControl class.

2) I have an Event called MyList() in Main Class, how can I raise this event in TLBoxEditingControl class.

Here is the code i use, This is not working please expalin

Public Class MyGrid
Inherits DataGridView
Public Event MyList()

[code]....

I have added this control to a form and added this code

Private Sub MyGrid1_MyList() Handles MyGrid1.MyList
MsgBox("ggg")
End Sub

Here the event is not raising.

View 1 Replies

Trigger An Event From Within Another Class?

Jun 5, 2009

In .NET I have a class called Caption. I have another class called Gauge. Within the Gauge class I have a property defined as a Caption.I am trying to figure out how to do thefollowing:When a certain property is changed in my Caption class how do I get it to execute a subroutine in the Gauge class? I am thinking I have to declare an event and AddHandlers to fire it off, but I can't think of how to accomplish this.

View 2 Replies

Using The Same Name For Event And Method Of Class?

Aug 15, 2011

am writing a class that has the same name for events and method, but visual studion won't allow me

The event
public event Close()
the method
Public Sub Close()
End Sub

how can i do this, i don't want to use different names

View 3 Replies

Add Event To Public NotInheritable Class?

Dec 24, 2009

Can i add an event to a Public NotInheritable Class?, in particular i would need to have an event that would listen to property change.System.Web.ClientServices.ConnectivityStatus has a property IsOffline, i would need to know when this property has changed?

Any other way to achieve this?VB.NET to C#[URL]..

View 1 Replies

Event Handling An Abstract Class?

Jul 6, 2010

Basically, I have a custom child form class which has events that will be passed to the parent. In the custom child form, I have a declaration of a "MustInherit" class that inherits the DevExpress User Control Class.

The reason for this, is I have many user controls that derive from this base class, and the child form can have an instance of any one of these controls, and doesnt care which. The only requirement is that the child form can handle the same events from each type of control the same way.

Some watered down code snippets(still pretty long unfortunately):
'''Inherited Class
Public Class ChildControlInheritedClass

[Code].....

View 1 Replies

Making Variable Class With Event?

Jun 22, 2010

I haven't quote grasped this whole "class" concept yet, but I'm working on it. When following the instructions below, the "test" portion of this code: "test.variable". It has an underlined error that says that "test" is not declared. If I remove the "test" word then the ".variable" shows not declared. I'm using Visual Studios 8 if that makes any difference. I have a pre-existing variable in a project that I would like to monitor for changes.

Re: Detect variable change.
Make your variable a class with an event.
Make your class:
VB.NET Syntax (Toggle Plain Text)
Public Class myVar
Private mValue As Integer
Public Event VariableChanged(ByVal mvalue As Integer)
[Code] .....

View 1 Replies

Pass DataTable Event To Class?

Apr 17, 2012

I have a form that contains a DataTable variable (dt) that has a RowChanged event assigned to it. I use a UserControl (DataGridViewFilterAndSorter) to get a subset DataTable from dt. I need dtSubset to have the same event as dt. How can I do this?

In other words, I need to pass the dt event to the DataGridViewFilterAndSorter class and store that event as a class level variable. How can I do this?

Public Class frmCalculatedResults
Private dfs As DataGridViewFilterAndSorter
Private WithEvents dt As DataTable

[Code].....

View 4 Replies







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