Custom Class As An Array Of Properties?

Sep 30, 2009

I'm moving my first steps in the VB.NET world (I come from VB6) and I'm stuck with the creation of a particular class.

Let's say we have a bus that always has 101 places. I'm trying to create a class containing the map of the bus, along with methods to graphically represent it.

My "Bus" class will have a couple of properties ("BusColor", "BusModel") related to the whole bus. Then it should have a property called "Places" whose type is a custom class thet represents every single place, along with, for example, the passenger name or the place number. This property should of course be an array.

This is my code so far (simplified):

Public Class BusMap
Private Const MAX_PLACES As Integer = 101
Private _BusModel As String = ""

[Code]....

but I wonder if there is a more standard way of doing this.

My second question is: how can I modify my class to be able to iterate its Places property with the "for each" statement? A quick search on the web showed up that I should implement the IEnumerable interface, but I'm still not enough confident with the concept of Interfaces.

View 6 Replies


ADVERTISEMENT

Create A Custom Class That Has Inside An Array Of Another Custom Class?

Jan 31, 2011

I want to create a custom class that has inside an array of another custom class (see my code below) but when the programm runs is crashes. Why? What is the right expression???? Plz help I'm a newbie in VB.net.....

Public Class ctrarray
Public nameclass As String
Public ctrlindex(glvar_spaces) As ctrlindexclass
End Class

[code]....

View 6 Replies

Get Properties And Methods For Custom Class?

Oct 29, 2009

Is it possible to iterate through the properties and methods of a custom class, getting the details about those properties and methods in the process.[code]....

View 2 Replies

.net - Not Retaining Changes Made To Values Of Properties In A Custom Class?

Jun 10, 2011

I created this function to remove vbCrLf from the values of properties in a Custom Class:(vTransaction)

Public Function ValidateTransaction(ByRef vTransaction)
Dim property1 As String
Dim value1 As String
For Each p As System.Reflection.PropertyInfo In vTransaction.GetType().GetProperties()
If p.CanRead Then

[Code]...

Throughout testing I can verify that vbCrLf is being replaced with a space as expected. When I re-examine vTransaction the changes have not been retained and the vbCrlf's are still there. What do I need to do to retain the changes being made to values in vTransaction.

View 1 Replies

How To Bind Custom Class With No Strongly Typed Properties

Mar 10, 2009

I need a simple class with only one Public property and no Public methods (the final Class will be more complex, but for testing this is all I need). The Property is "Item" and takes a "String" as a parameter. It returns a "String" based on the parameter. I then want be able to add instances of this object to a List or Array, and then Bind it to a Repeater or a ListView......most importantly, I want to be able to then refer to values in my simple Class via the Eval function:
<%# Eval("SomeIDString**") %>**.

I can't Bind at all unless I declare the Item property as the Default property...why?
When I use "Eval", I get an error in the lines of "[some property] does not exists". indeed it doesn't, because everything is accessed via the Item property. it then does works if I replace "Eval" with "Container.DataItem". Is there a way to use Eval instead of Container.DataItem? I would rather not have my class inherit any other classes because I want to keep it clean from supurfulous properties and/or methods.

Are there interfaces I need to implement? Also, the reason I want to use Eval, is that as much as possible, I want to make the use of this Class simple, so the coder doesn't need to worry about special cases. I just want it to work, much like the DataTable Class, but with a much simpler, lighter-weight implementation.

View 3 Replies

VS 2008 Custom Class Called CustomItem That Holds Name And 'SomeProperty' Properties

Apr 22, 2009

Let's say I have a custom class called CustomItem that holds the Name and 'SomeProperty' properties:[code]Now, on the click of a Button, I want to select the CustomItem whose SomeProperty is equal to "Property 4". Of course, this is just "Item 4", but the names and properties are not that correlated in the real application than they are in this example.I have spent ages a long time ago figuring out how to do this. I could not directly set the SelectedItem, because I first need to get the CustomItem that actually matches my condition (SomeProperty = "Property 4"). My solution was to use a loop, looping through each item in the ListBox, and setting the SelectedItem when the right property has been found.[code]Now, is this the correct way to approach this problem? Is the LINQ query correct, or can it be done easier, without the casting? Also, is the LINQ query faster than the For loop, especially for a large amount of items? I expect it to be, but I don't know how to test this.

View 4 Replies

Get Custom Properties For A Custom Control Into The Visual Studio Properties List?

Nov 25, 2009

What I've done is create a User Control Library (Project) and I've added a single User Control to that project. The control contains a single FlowLayoutPanel, and I created a Property on the control itself to pass the FlowDirection from the Control to its FlowLayoutPanel child.

Build, reference, component appears in the Toolbox and everything works fine, but the property on the control does not appear in the Properties window when I go to edit it at design time.

View 6 Replies

Include An Array In Class Properties?

May 21, 2010

I am trying to build a class that includes an array so that I can refer to each element in the array. For example, let's presume I'm building a class that includes student id, student name, and then an array of 8 courses (numbered 0-7). I'd like to be able to refer to:

baseClassName.Course(0)
baseClassName.Course(1)

etc...but I know that's NOT how it's done...but how IS it done?

View 7 Replies

.net - VB Datagrid + Array With Custom Class?

May 14, 2012

I have created a class "student" and made an array which contains students.I would not only like to display the array in a datagridview, but the array should also be updated if the user makes changes to one of the students in the datagridview.

I succeeded in showing the array in the dgv: one way is using datasource prop, the other is doing is diagrammatically. However, i can't find out how to let the user edit the array by editing the dgv.

View 1 Replies

Dynamic Array Of Custom Class

Jun 16, 2009

I've been programming in VB.net for a while off and on, but never really had a need to use custom classes till now.I built a function in a module to populate a class, The class how ever is supposed to refer to one instance.I need to create an array of this class but the amount of instances needed is not always known.Works fine till the class goes to populate the class array.[code]It's probably something simple, I've just starred at it to long. Keep gettitng "Object reference not set to an instance of an object."

View 1 Replies

VS 2010 - DataGrid Custom Class Array

May 14, 2012

I am working on a project which lets the user edit the students in a certain group using a datagrid. First I created a class called student and then I created a student-array. Displaying the students in a datagrid works fine. On form-load, I change the datagridview.datasource to the student-array. The datagrid has 20 rows by default (Public dbstudebt(0 To 19) As student). When I edit an existing student everything works fine but when I fill something in in an empty cell and press enter or tab to confirm and add a new student, it just clears the cell and nothing happens. So basically, editing existing studs in the datagrid works fine, making new student doesn't work at all as those cells are always cleared immediately.

View 4 Replies

Create A Custom 2 Dimensional Array Datastructure/class?

Jun 21, 2010

I want to create a user defined data structure, which will be a 2 dimensional array such that each individual square of this 2-dimensional array will also store the score and the grades. ( Iam using VB.NET) More details:

for example: There is an 2 dimensional array with 3 columns and 2 rows, I want to fill each of the

(0,0);(0,1);(0,2) with their own score (Integer type) and grades (String Type).

And this is same for the rest of the squares i.e. (1,0);(1,1);(1,2) and (2,0);(2,1);(2,2)

After creating such custom data structure: "CustomArray", I should be able to create the instance of this custom data structure (which will be a class) and code something like this:

Dim objCustomArray as CustomArray
objCustomArray = New CustomArray
for i as Integer =0 to 3

[code]....

View 2 Replies

Custom Class With A Public Property String Array?

Jan 5, 2010

I am trying to create a property of type string array (if this is possible).....and I seem to be lost.

I tried the following, but it says "String cannot be converted to '1-dimensional array of string'" at the return

Private _strZipList As String()
Public Property strZipList(ByVal i As Integer) As String()
Get

[Code].....

View 10 Replies

Make Custom Properties In Properties Window To Refresh Upon Change Via Code?

Apr 26, 2012

[code]I want to make the Properties Window to update the properties for X and Y at each MouseMove, so they become immediately visible for the user.

View 2 Replies

PropertyGrid Custom Properties - Custom Sub Properties

Oct 21, 2009

I've populated a PropertyGrid with a custom class. How do you create and display a sub property similar to Size (Height, Width) which has two values or Point(X,Y)? For example, the class is Test and the property is Item as string. I want to expand Item to have two sub properties, A and B.

View 1 Replies

Can't Inherit Shared Properties From A Base Class In A Child Class?

Dec 29, 2010

This is another one of my "I think it's not possible but I need confirmation" questions.I have a base class for a bunch of child classes. Right now, this base class has a few common properties the children use, like Name. The base is an abstract class (MustInherit)Technically, this means that everytime a child class is instantiated, it lugs around, in memory, its own copy of Name. The thing is, Name is going to be a fixed value for all instances of a given child. I.e., Child1.Name will return "child_object1", and Child2.Name will return "child_object2".

View 1 Replies

Class With Class Properties: AObject Reference Not Set To An Instance?

Aug 19, 2009

I have a class in which some of the fields are also classes.I can put values in the "normal" properties, but in the others when o try to assign values it gives the: "Object reference not set to an instance of an object"But the code compiles fine.

dados_Defenicao = New ServiceReference1.draftClaimEntryDefinition
dados_Defenicao.arCode = "123"
dados_Defenicao.claimMarket.warrantyType = "w" - Here it gives the error

How can i fix this ?

View 6 Replies

Class With Class Properties: Object Reference Not Set To An Instance

Aug 19, 2009

I have a class in which some of the fields are also classes.

I can put values in the "normal" properties, but in the others when o try to assign values it gives the: "Object reference not set to an instance of an object"

But the code compiles fine.

dados_Defenicao = New ServiceReference1.draftClaimEntryDefinition
dados_Defenicao.arCode = "123"
dados_Defenicao.claimMarket.warrantyType = "w" - Here it gives the error

View 4 Replies

VS 2010 : Copy This Array To A Temp Array So That The Temp Array Has All The Same Values As The Original Custom Array?

Jun 19, 2011

I have an array of people stored in a custom structure array... how can i copy this array to a temp array so that the temp array has all the same values as the original custom array?

View 4 Replies

Interface And Graphics :: Making A Custom Class That Mocks The System.Drawing.Rectangle Class?

Jul 6, 2010

I'm making a custom class that mocks the System.Drawing.Rectangle class because the Rectangle class doesn't have a name property. I need a name property because I am adding all of my rectangles to a collection and I need a little more info stored than just their locale and size. So I changed the _onPaint event but nothing is working out when I run the program?

Public Class Rectanglar : Inherits UserControl
Public BackgroundColor As Color = Color.Blue
Public Sub New(ByVal name As String, ByVal XY As Point, ByVal Widthy As Integer, ByVal Heighty As Integer)

[code].....

View 5 Replies

Asp.net - Custom Profile Properties In MVC 3

Jun 14, 2012

I need to implement some (maybe 10) custom properties for logged in users for my MVC3 vb.net web app. These will define how certain data is displayed within my views. I can think of a couple of possible solutions..

[CODE]....

View 1 Replies

Custom Attributes & Properties

Aug 25, 2009

I was thinking to put attributes on BLL classes properties which ever are mandatory and I'm successfully able to retrieve the attributes also. But, not I also want to check the value of propeties. How I can do that:[code..]

View 1 Replies

Custom DataGridViewColumn Properties?

Jun 21, 2010

I created a custom datagridview column for a progressbar and included customizable color properties but I can't get them to work right. After compiling, the properties show up correctly in the Edit Columns popup editor, but changing the values has no effectThe designer generated code shows the original values and manually changing them there has the desired effect(I know you're not supposed to, just testing). Here is the code for the column even though I don't think the issue is stemming from any coding errors there.

Imports System.Drawing
Imports System.ComponentModel
Imports System.Drawing.Drawing2D

[code].....

View 2 Replies

DataGridView Custom Properties?

May 31, 2009

I'd like to add some custom properties to the columns of my DataGridView control. I'm not sure how to do it.I tried this once before but never got it finished. Basically, I'm making a teacher gradebook. Fore each column, I need to add properties called Assignment,DateAssigned, DateDue, PerfectScore, AssignmentType, etc.

View 6 Replies

.net - Group Properties In A Custom Control?

Apr 16, 2009

In our IDE, for example, Visual Studio, if we display the properties of a System.Windows.Forms.Button control, we see some properties that expose anoter set of properties. For example: FlatAppearance, Font, Location, Margin, etcetera.I would like to do something similar in a custom control.I know the code behind is wrong, but here is an example of what I´m trying to do:

Public Class StateOfMyCustomControl
Public Enum EnumVisibility
Visible

[code]....

In my IDE, in the properties window of my custom control, I would like to see my property State, with the possibility of display it to set the properties Visibility and EventManagement.

View 1 Replies

Add Custom Properties For Windows Service?

Oct 22, 2009

I have developed a Windows service application in VB.NET.My need is to have custom property tab like "General", "Log On", "Recovery", and "Dependencies". Because I need to configure my service and also want to display some extra information in that extra tab.

View 2 Replies

Custom Dialog - Pick Properties ?

Jul 15, 2009

Lets say i'm making a new dialog. I don't want to expose the properties of the form to code elsewhere, only specific ones I define. I tried making the form Protected (including the Designer generated code) and putting it in another class, but then I can't figure out how to access the form from my code. Am I going about this completely the wrong way, or what?

Code:

View 5 Replies

Group Properties In Custom Control?

Apr 10, 2012

I want to do a class that have properties like font, which will have other properties, such as name, size, unit,bold.

<TypeConverter(GetType(ExpandableObjectConverter))> _
Class TestingClass
'Some property here
End Class

View 1 Replies

Reusable Custom Control With Properties?

Nov 13, 2009

I have built a Custom Control Class that makes it much easier to build a side bar element in my html.

The problem I am running into is that when I set the "Text" property, the last time I set it gets used for every instance of the control on my page. This is my first time doing this, so I'm assuming I'm missing something basic.

[Code]...

View 1 Replies

Set The Properties On A Custom Control In The Designer?

Mar 21, 2010

Is it possible to make a form that can set the properties on a custom control in the designer? What I mean is I want to know if it is possible to show a dialog that allows you to set the settings for a certain property like if you were adding items to a listbox.

View 3 Replies







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