Why Does List.Clear() Also Get Rid Of A Class Property

Oct 4, 2011

I have the following class:

[Code]...

I could be way off here, but it almost seems like ID.IDlist points to the address of mylist and so when mylist is cleared so is ID.Idlist. It seems as though the reason the second block of code works is because I am creating a new list in memory for each ID object and ID.IDlist just points to it... is that right?

View 2 Replies


ADVERTISEMENT

Adding A List (of Class) Or Collection As Another Class's Property

Apr 2, 2010

I'm looking for a tutorial on how to Adding a list(of Class) or Collection as another Class's Property.What I am after is something like the Columns Collection for the DatagridView control.I would like to add Items in the graphics screen. Where the item list is displayed in the left panel and the selected Item properties are displayed in the right panel.

View 4 Replies

.net - Overrides A "list Of Base Class" Property And Returning A "list Of Child Class"

Oct 19, 2010

I have a base class (ex: Class1) containing a list of another base class (ex: ClassA). Each child class of first base class (ex: Class1AA, Class1AB,..) containing a list of child class of second base class (ex: ClassAA, ClassAB,...)The client must never know which child class is using, then i don't think i can use generic for my bases classes.I try something like this and many more, but i always received errors..Imports System.Collections.Generic

[code]...

View 1 Replies

.net - Get A Class Property To Be A List Array?

Oct 14, 2009

Stack Overflowers:I have been racking my brain trying to get an List(of T) type array to be the property of a class. I know there has to be a simple way of doing it and I can't find a good example on google. Everytime I create a class that I think will work I get the "Object reference not set to an instance of an object" error when I try to use it. My thinking now is that I cannot use it in the way I was hoping to. Here is my latest attempt:

Public Class Item
Private _itemno As String
Public Property ItemNo() As String
Get

[code]....

View 2 Replies

Continuation Of A List (of T) As A Property Of A Class

Apr 2, 2010

This is another continuation of an issue with a List(of T) as a property of a class.Following the excellent advice of AtmaWeapon and others on this forum, I have my classes working fine except for something that is inexplicable to me.I initialize my "course" class at a public level in a module. This is so the data in the class will be available program wide and for the application's lifetime. "Public newCourse As New Course".I initialize a local instantiation of the class TimeTable as newTimeTable [code] This issue is: The List(of T) is populated with data, however, when the loop finishes, what I have is the last set of values repeated "X" number of times in the List instead of the data being different in each element of List( Of T). [code]

View 2 Replies

Sort List Of Class Using Id Property?

Oct 8, 2010

I have a class called Questions. This Questions has properties QuestionID and QuestionAnswer. My list of Questions has QuestionID like 2, 3,4, 15, 12, 24,22,,,, etc.I need to sort this List of Questions Object based on QuestionID and store in another Questions object.

View 2 Replies

Bind A Class Property That Returns A List To A DataGridViewComboBoxColumn

Mar 12, 2011

I have a file name that is found at multiple paths. I want to present this data to the user in the format of a DGV. I have a DGV with one text box column for the name, and another combobox column for the paths. I am having trouble getting the combobox column to bind to the property of the class that returns the paths.

[Code]...

View 1 Replies

Create A User Control With A List Of Custom Class Type Property

Nov 29, 2011

Is it possible to create a user control with a list of custom class type property? If it is, how can I? The issue is that, in designer mode the property is not displayed in property window. I can add the list on markup but when i switch to the designer mode it gives an error which is 'The user control does not have a public property named BookList'.

View 1 Replies

VS 2005 Code For Clear List In List Box?

Aug 23, 2011

I want to know what is code can be write for clear all item in list box??..Here i attach my code for looping for.This looping will display are result in list box. For info i am using visual studio 2005.Public Class Form1

Private Sub btnLoop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOnWard.Click
Dim num As Integer

[code].....

View 2 Replies

Using A List (of T) As A "Property" In A Class?

Oct 20, 2010

In my application I have a class called "RCategory" as illustrated here:

Public Class RCategory
Public Property RCatNum As Integer
Public Property RAct As Char

[code]....

I'm trying to add to my list using the following code:

For ct As Integer = 1 To 8
Dim c As New RCategory With {.RCatNum = ct,
.RAct = dr("RACT" & ct.ToString).ToString,

[code]....

I'm getting an error when I get to the bottom line, though...when I actually execute the RCat.Add(c),I get a System.NullReferenceException was unhandled by user code Message=Object reference not set to an instance of an object. What must I do to be able to use a List (of T) in my class?

View 3 Replies

Can't Clear Textbox Text Property When It Contains A Numerical Value

Oct 6, 2011

I'm trying to write a Database manager in VB (2010) that updates a SQL database that compiles and summarizes my financial records. The code works, but I'm having issues with one exception that I think I understand, but can't circumvent. I've built an I/O form that enters a series of purchases and sales into a temporary datatable. After review of the list, the program connects to the database and executes the SQL. That all works and isn't a problem.

[Code]...

View 3 Replies

.net - Make A Class Property Behave Like The Checked Property On RadioButton?

Jun 1, 2012

I have a very simple class that holds a few public properties - ID, Text, Colour, etc. and a Boolean called 'SelectedItem'. Just like the Checked property on RadioButtons, only one item can have its SelectedItem property set to True within a particular group. Note: there will be several separate groups (lists), each allowed to have only one item with SelectedItem = True.

My first thought was that I would probably just have to handle everything outside of the class, setting SelectedItem to False for every other item in a particular list when another item was selected. But that seems rather inelegant to me. So I've been trying to think of how this might be done within the class. For example: could I perhaps have a private string property called say "GroupName" - set in the New sub when adding a new instance of the class - and then use a private shared method to set every item's SelectedItem property to False, provided the item has the same GroupName as the newly selected item? I would have a go at doing this but I have no idea how to enumerate every instance of a class from within that class, or whether that's even possible. Is it? Or is there another (better) way to achieve my goal? Here is a cut-down version of what I've got so far:

Public Class ResourceItem
Public ID As Integer
Public Text As String[code]....

As can be seen: instead of instantiating a new ResourceItem and passing that as an argument to the manager's Add procedure, I'm simply passing the details of the new item and the procedure is creating the item from those. I don't know whether this is a good or bad idea - please advise - but I've done it because I couldn't figure out how to make the SelectedItem property only writeable by the manager, so I wanted to avoid having directly accessible objects that could have their SelectedItem property set to True without it deselecting all the other items in the same group. Of course that still leaves the possibility of setting a variable to one of the manager's list items and setting it from there, so I would still like to know how I could prevent that, if possible.

UPDATE: I didn't use the code above in the end, deciding instead to go with Cyborgx37's solution - which seems to work perfectly well for me despite the warnings about best practice. I also realised I would need to use the same class in another scenario where multiple items could be selected, so it was easy to add a Boolean property to the manager to enable that.

View 2 Replies

Clear All Properties In A Class?

Jun 9, 2010

Is there a way to clear all the properties in a class, because i have a class where all my properties were stored, can i clear all those in just a short code?

View 6 Replies

IDE :: Make A Property In A Property Grid A List Box In 2010?

Feb 21, 2011

I have the following property in a property grid in VB.Net 2010.

<Description("Rapid Entry Post Car Wash Settings CarWashOptionPushButtons"), _
Category("Post Car Wash")> _
Public Property CarWashOptionPushButtons() As String

[code]....

I need to make this property a list box that gets the values from a database table and populates the list box with the values from the table. I have tried numerous things to no avail.

View 4 Replies

Clear An Array List?

Sep 13, 2009

Is there a clear command that I can use on an array list, I try to use clear but something is wrong here[code]...

View 5 Replies

Clear Checked List Box?

Jun 22, 2009

It's been a while since I've used VB and I cant seem to remember how to clear/reset a checked list box. I can clear a check box and list box, but not the checked list box. While we're on the subject... what's the proper prefix for a checked list box? I've just been using clbListBox but I dont think that's correct.

View 3 Replies

How To Clear DataGridView List

Aug 31, 2009

datagridview1.rows.clear()
And this one
me.datagridview.rows.clear()
It says I cannot clear the datagridview list.

View 3 Replies

VS 2008 Clear List?

Oct 25, 2010

How can i clear this list. Is this list called Recent or?

View 8 Replies

Having A Class Property Dependent On Another Property Opinion?

Aug 13, 2009

I have the following code:

Public Class MyColorsClass
'Constructors
Public Sub New()
'Empty Constructor

[code]....

However, if the empty constructor was called to instatiate this class then the colortype is not yet set. Therefore, if one accesses the 'IsColorCool' property it will always return 'False'. Now for the sake of this example, I must keep the empty constructor as part of the class.Now I could add some code in the 'IsPropertyCool' to check and see if a ColorType has been defined, and throw an exception if it has not been set, but I don't really want to do that.I also could always move the logic OUT of the property and into a method on the class called 'DefineIfColorIsCool' or something, and make the owness on the caller to make sure the method was called if they want to use the property 'IsColorCool'?

View 5 Replies

.net - Suppress A Property Or Method From A Base-class In A Derived Class?

Apr 7, 2011

Supose a base class

Public Class airplane
Private var_num_seats As Integer
Private var_num_engines As Integer

[code]....

Obviously, I don't wish that the class Glider has the method "start_engines" neither the property "num_engines". Otherwise, other child classes may have. How can I supress these property and method in child class, not just ignoring (if I can)?

View 2 Replies

Can't Set DataTable Class Level Variable = Class Table Property?

Sep 29, 2011

I have procedure (Import) that calls a for a new instance of frmImportData. I also have a class name clsBatch that has a data table property called prpParametersTable.For some reason, I get an error (indicated below with ERROR>>>) when trying to assign prpParameterTable to cv_dtImport2. The error states "Object reference not set to an instance of an object.". Why does this error not happen when I assign dtBP to cv_dtImport1? Both cv_dtImport1 and cv_dtImport2 are equal to Nothing and in my Import procedure dtBP = prpParametersTable.

Public Sub Import(ByVal clsB As clsBatch)
Try
Me.cv_clsB = clsB

[code]....

View 5 Replies

Class Property Usage - Unable To Retrieve A Variable From On Class

Nov 14, 2009

I have three class files, accounts.vb and transactions.vb in addition to my form.vb. I am unable to retrieve a member variable from on class from inside the other. When the combobox index changes, the program loads the correct account (checking or saving) from two different sequential files. I don't think I have the calcBalance procedure in the correct class file. And that is what I am having trouble with. Accessing it to display it. [Code]

View 1 Replies

Clear A List Box On Panel.hide?

Aug 15, 2011

I am using this code to clear the contents of my panel

For Each c As Control In PanelEdit.Controls
If TypeOf c Is RadTextBox Then
DirectCast(c, TextBox).Text = String.Empty

[Code]....

the idea is if a user opens a different panel and then comes back to the panel they were in all the data is cleared.

View 9 Replies

ComboBox Task - Clear List Box

May 20, 2012

I am trying to make it so when i choose a item in the combo box the list box is cleared i have tried these two codes and i cannot thing of any others but it does not work can someone help me? [Code]

View 1 Replies

Access Members Of A Sub Class Through A Property Of The Parent Class?

Mar 30, 2010

This is a bit of a continuation from a previous post for which AtmaWeapon was very informative.

Problem:
A parent class has a sub class with various properties. A property of the parent class is a List(of T) with T = the sub class The issue is how to store data in the sub class of the instantiated parent

Some example code (hopefully formatted correctly):

Code:
'=========== Class Definitions =============
Public Class courseClass
Public Class timeTableClass

[Code].....

View 7 Replies

Determine If Property Is Generic List<of T> Via Reflection And Loop List Items

Oct 1, 2009

I'm looping all the properties in an object via reflection:

For Each p As PropertyInfo In values.[GetType]().GetProperties()
If p.CanRead Then
'Do stuff
End If
Next

how to determine whether the property in question is a generic List(Of T)? If it is I need to loop the list itself.

I've experimented with GetType and TypeOf but have not managed to get anything working.

To clarify, I want to keep this generic. I do not want to specify the type of T, I need to loop the list items and call the ToString method on each item. T could be one of a number of different types (application specific reference types). Is it possible to do this without specifying types?

(VB.NET 2005 with .Net 2.0)

View 3 Replies

Clear A Asp Dropdown List And Populate Using Ajax?

Oct 13, 2011

What i am trying to do is get a user to change one drop down, which then calls an ajax function which posts to the code behind (vb.net file) then clears and populates another asp dropdown list with the data returned from the function..[code]...

View 2 Replies

Clear List Of String To Release Memory

Jun 11, 2012

Is it necessary to clear a List of String to release memory?Or is it done automatically?

View 1 Replies

VS 2005 OOP Classes - Can't Clear List Of Data Saved

Dec 3, 2009

bare with me here ok I posted on here a while back, like month to 2 months ago about creating an array of data (user inputed data). But was suggested to go the class route. After weeks of lengthly reading came up with a list collection class.

[Code]...

View 4 Replies

.net - Accessing Property Of A Class Without Inherting The Class

Apr 7, 2012

I have a class that has the following property that is generated by the methods in the constructor.

Public Class clsLoadTables
Private _ds As New DataSet
Public Property ds() As DataSet
Get

[CODE]........................

My problem is that I do not want to inherit this class, but I have other classes that need to access the ds DataSet property. If at all possible I would like to not use inheritance and not load my datatable more than once in the program.

Here is my failed attempt to access the property inside another class that is not inheriting clsLoadTables:

[CODE].........................

How I can access this dataset that I want to load only once in the program from many classes without using class inheritance or a global module?

View 3 Replies







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