Determine If List(Of Object) Contains Control Object ?

Nov 8, 2010

How to know if a List(Of T) contains any control object without using a loop ?This doesn't work

Dim lstObject As New List(Of Object)
lstObject.Add("STRING")
lstObject.Add(2)

[code].....

View 9 Replies


ADVERTISEMENT

Determine Which Object In An Object Graph Caused A SerializationException?

Jan 12, 2011

I'm deserializing an object and in certain cases it works fine, however in others it fails. The exception is essentially meaningless to me, but there has to be a way to figure out where exactly it failed so i redirect my debugging.

[Code]...

View 1 Replies

List Of T Find Date Or Other Property In A Object In The List - Then Return Found Object?

Sep 3, 2009

After reading all the examples for list of T exists and Find and find first, none show how to handle multi-property objects. Below is bare bones example maybe someone could flesh out to show how this should be done.

Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim DatePriceList As New List(Of DateAndPrice)
DatePriceList.Add(New DateAndPrice(Date.Parse("1/1/2000"), 10.12))
DatePriceList.Add(New DateAndPrice(Date.Parse("1/2/2000"), 11.12))

[Code]...

View 3 Replies

Display A List (Of Object) Which Has Single Objects And Child List (Of Object)?

Sep 6, 2011

Limited to using v2.0 of .Net framework (we use VB.net) due to environmental constraints on our servers.I've got an ASP.net webpage which pulls data from a webservice that performs checks on user accounts in active directory. Operators can check multiple accounts at one time using the web interface. The webservice returns a list(of AccountCheck) objects which themselves contain single properties like username, email address, and List(of AccountError) objects which contain multiple properties.[code]What I want to do is using some kind of repeater, create multiple panels or divs which contain labels showing the username, email etc, and a gridview which has the accounterror list bound to it to show all the errors. The users could be checking 2, 5, 7 accounts at once, and is dynamic.

View 2 Replies

Cast A List Of Object To List Of Interface That Object Implements?

May 19, 2009

I am working in VB.net and have a Class, Foo, that implements an interface, IBar.I have a List of Foo's, but I need to pass a list of IBar's into a function, but I keep getting casting errors, even when I use DirectCast.My code is [code]MainWorks works, but it would be really annoying and inefficient to have to do that everywhere I want to call this function.

View 4 Replies

Does An Object Retrieved From A List Get A Copy Of That Object Or A Reference To It

Feb 1, 2012

In VB.net, when I retrieve a value from a list do I get a copy of that value or a reference to it?

dim blah as someObject
dim listOfBlahs as list(of someObject)
listOfBlah.add(new someObject(1))

[Code]....

View 2 Replies

Why Is List.add() Adding Items To Object AND Source Object As Well

Jun 15, 2011

I need to be able to add elements to a copy of mylist.testlist without modifying the global mylist object. (Which seems to be happening via the below code.)When I am working on x, which should be a totally separate object, mylist is getting modified as well. How can I fix this? I have worked with lists extensively and never seen this behavior before. I have tested and reproduced the problem in .NET 3.5 and .NET 4.0 on Win 7 Pro 32bit.

Source Code:

Public Class Form1
Public mylist As New test
Sub Main()

[code]....

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

Wpf - Object Reference Not Set To An Instance Of An Object When Using Custom User Control

Feb 10, 2012

I have created a custom user control (JCUserControl), and I am using it in the Main Window. And my Main Window has no codebehind. I have this in the JCUserControl codebehind:

Private Sub ImmediateRadioButton_Checked(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles ImmediateRadioButton.Checked
SomeTextBox.IsEnabled = False
End Sub

When I run it, it fails with the NullReferenceException. If I comment out the SomeTextBox.IsEnabled = false, it runs without any problems.

Edit: Found out that I could just check if the radio buttons are loaded before doing whatever I want to do.

Private Sub ImmediateRadioButton_Checked(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles ImmediateRadioButton.Checked
If ImmediateRadioButton.IsLoaded Then
SomeTextBox.IsEnabled = False
End If
End Sub

View 1 Replies

Disposing Object Collected In List (Of Object)

Jul 29, 2010

I would like to ask what is the efficiency way the clean and dispose the object collected in the List (Of Object)?

Is that by calling the List.Clear() method will automatic clean all the object collected by it?

View 7 Replies

VS 2008 Remove Object In List(Of Object)?

Feb 11, 2011

I am able to populate an object and output everything. How do I remove say the name2 object?

la.Remove(Logins("name2")) doesn't seem to work.
Private Sub btnListArray_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnListArray.Click

[code]....

View 9 Replies

How To Quickly Transform A List(Of Object) Into A List(Of "Object.field")

May 29, 2012

Suppose I have a list of Cat.

Public Class Cat
Public Property id As Guid
Public Property name As String
Public Property race As catRace
End Class

How can I quickly transform this List(Of Cat) into a List(Of Guid) using the id property?

I could do :

Dim newList As List(Of Guid)
For each item in catList
newList.Add(item.id)
Next

But I think there must be a way to do this faster (1 LOC). I just can't find how.

View 3 Replies

Asp.net Mvc - Creating A List (of String) Giving Error" Object Reference Not Set To An Instance Of An Object"

Nov 1, 2011

MVC 3 razor VB.NET project. I have resorted to manual building a list for a drop down box so I can insure certain values are available in the select list and also to control what the first item is in the list. The below is my code snippet for the part that is giving me problems..

[Code]...

View 2 Replies

VS 2010 "Object Reference" Error When Adding Object To List (Of T) Property

Apr 25, 2011

I have a class that has a property that I declare like this:

VB.NET
Private _DirectoryList As List(Of FileDirectoryInfo) ''' <summary> ''' Array of directories. ''' </summary> ''' <value>Object</value> ''' <returns>Directory array list</returns> ''' <remarks>N/A</remarks> Public Property Directory As List(Of FileDirectoryInfo) Get Return _DirectoryList End Get Set(ByVal value As List(Of FileDirectoryInfo)) _DirectoryList = value End Set End Property

[Code]...

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

.net - Determine Is An Object Is A Structure?

Mar 4, 2011

I'm looking for a similar "IsStructure" function. Is there some other way to determine if T is a structure but not an intrinsic type?

Public Shared Function MySub(Of TData)(ByVal t As TData) As TData
Dim IsClass As Boolean
IsClass = GetType(TData).IsClass
End Function

Note that using IsPrimitive and IsValueType on Nullable(Of Integer) and a Structure returns the same results, False and True, respectively.

View 2 Replies

.net - Determine The Size Of An Object?

Aug 22, 2011

Public Class A
Private aa As Integer
Dim bb As Integer
Public cc As Integer

[code]....

what is the size of the object oA?and what if Class A and B contain methods?(I meant the size of object)what if inherited class B contains overridden methods?(size of object)what if inherited class B contains variables with same name as in Class A?(size of object)I need theoretical answer. Does those access specifiers Private,Dim,Public make any difference in allocating memory because of their different scopes?On what basis memory is allotted for a method? etc.

View 1 Replies

Determine If An Object Is A DateTime?

Oct 22, 2010

The following works fine in c# (assuming value is an object):

if (value is DateTime)

What is the equivalent check for VB.NET?

View 3 Replies

Copy List Object To Another List Object

Jun 15, 2012

I am having a problem when setting VB.NET list object to another.I create an instance on ReadLocations and than create an object of ReadLocation where then I loop through ReadLocations and set ReadLocation1 equal to rl. What happens is that if I then go and change ReadLocation1 to something else (assdfhsd) it will also change the ReadLocations index. I am really confused why it would be doing that unless it is "=" sign means referencing instead of actually setting the value. Please help as I am a C# developer but the program I am modifying is in VB.NET.[code]

View 1 Replies

Determine The Type Of A Passed Object?

May 19, 2009

I am still developing this function, but here is what I am intending it to do. This function will accept an Object, then try to determine its type. There are a specific set of types I am looking for: Integer, Boolean, Date, String. What I have so far is pretty privative, but it seems to be working so far:

Private Function DataType(ByVal entry As Object) As ValueType
Try
If IsNumeric(entry) Then

[Code].....

View 3 Replies

Determine Type Of Object In A Collection?

Oct 28, 2009

I can't figure out how to determine the type of an object in a collection. I want to do a For Each ... Next loop over the items in the DropDownItems collection of a ToolStripMenuItem. For those items that are ToolStripMenuItems themselves I want to take some kind of action. (The collection can contain other types of items, such as ToolStripSeparators). So I need to say something like: If Typeof(item) = ToolStripMenuItem Then .

View 1 Replies

Determine Whether Graphics Object Is For A Printer?

May 11, 2009

We would like to know whether there is any way to interrogate a Graphics object and determine whether it is to be used to print or to render to some other canvas. We're aware of an API call that can be used but would prefer to avoid that route if possible. There's also the possibility of simply passing a flag in with the Graphics object that is True from a PrintPage event handler and False from elsewhere, but that's not ideal either. We're looking for a managed property or method accessible via the Graphics class itself, but nothing's jumping out.

View 20 Replies

Determine What Type Of Object Is The Sender Of An Event?

Nov 25, 2011

Heres my sub:

Dim onThisTable as String ="Name"
Private Sub skill_mouseHover(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1.MouseHover, button2.MouseHover, panel1.MouseHover, panel2.MouseHover, pbox1.MouseHover

[Code]....

Now I wish to give onThisTable a different value depending what the user pass over (panel or a pbox or a button) but I cant find what is the correct way to compare what type it is ...

Private Sub skill_mouseHover(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1.MouseHover, button2.MouseHover, panel1.MouseHover, panel2.MouseHover, pbox1.MouseHover

[Code]....

View 1 Replies

.net - "Object Reference Not Set To An Instance Of An Object" Trying To Add To List?

Dec 19, 2011

I've created A list of object "emails" which contains the "email" object which has 3 parameters (String Address, String Subject, String Body)I then want to add to the list by creating more instances of "email". However, I've tried so many different ways and it's having none of it.

Public Class Test
Public emails As List(Of Email)

[code].....

If I click button1 I get the error "Object reference not set to an instance of an object".

View 1 Replies

Determine That An Object (button) Make Collusion With Clone Of Itself

Jul 10, 2011

Let's say we have object A and object B (Picturbox for e.g) Iwant to move A from its position to B's position straightly .what is the mathmatical equalation to get the X,Y coordinator that A must move from its position straightly to B's positionI have another thing ,I would like to know how can I determine that an object (button for e.g) make collusion with a clone of itself.

View 1 Replies

Determine The Type Of Object To Use To Store A Linq Query?

Jul 3, 2010

I am using VB .Net for this, so I don't have access to var or this would be a simple matter.Right now my query is as follows

[code]...

So I used this query in LinqPad to help me determine what the object would look like. I got back a IOrderQueryable(Of RSError) which then contained a IGrouping(Of String, RSError) for each grouped collection of objects returned by the query.However I ended up with the current object type of errors as IOrderedQueryable(Of IGrouping(Of String, RSError)) because of the cast error I am getting in VS.

[code]...

I'm not sure how to get rid of the VB$AnonymousType_1 Part of the returned object.Am I even on the right track here or am I missing something completely?

View 1 Replies

C# - WCF Serialization And Interfaces - Error: List(of Object) Cannot Be Converted To List(of IMyInterface)

Oct 16, 2009

Does link text mean I have to return a concrete implementation? Even though I am using svcutil with the /r that includes my entites(where IMyInterface is defined). I get no errors but it changes all List(of IMyInterface) to list(of Object) and I cannot deserialize it on the client

Error: list(of object) cannot be converted to list(of IMyInterface).

View 1 Replies

Create List Of Child Objects From List Of Parent Object?

Jun 2, 2011

I would like to create list of child objects from list of parent object. Like If i have list of bookingroom which has one member room then i would like to create list of room from it.

eg. code:

Dim BookingRoomList As List(Of BookingRoom) = New List(Of BookingRoom)
Dim RoomList As List(Of Room) = New List(Of Room)
BookingRoomList = BookingRooms.FillGrid()

[Code]....

Is there any short cut method instead of iterating over for earch?

View 1 Replies

Error - LINQ To Entities Does Not Recognize The Method 'System.Object IIf(Boolean, System.Object, System.Object)'

Jul 29, 2011

I am getting following error whenever I want to use IIf function inside entity framework query.

LINQ to Entities does not recognize the method 'System.Object IIf(Boolean, System.Object, System.Object)' method, and this method cannot be translated into a store expression.

View 1 Replies

.net - Searching A List Of Objects In An Object List Using Linq?

Dec 22, 2010

I have 2 classes

Public Class Shipper
Public Property ShipperID As Long
Public Property CreateDate As DateTime

[Code].....

View 1 Replies







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