473,221 Members | 1,993 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,221 software developers and data experts.

<cannot view indexed property>


Hi,

I have created a collection of a custom class. Everything works fine (can add these items in a combo from within a VB.NET application, for instance), but when looking at the collection from a VB.NET application in the Watch window, I cannot see the items of the collection. The message in the Watch window's "value" says: "<cannot view indexed property>." Below is the code I wrote.

Any idea of what is wrong? Or is the error message "correct"?

Thanks a lot.
Mike


public class Companies : IEnumerable {

ArrayList m_oCompanies = null;

public Companies() { // Nothing is done in the constructor. }
public void Add(Company oCompany) {...}
public Company this[int index] {
get { return (Company)m_oCompanies[index]; }
}

public int Count { ... }

}

public IEnumerator GetEnumerator() { return new CompaniesEnumerator(m_oCompanies); }

// Inner class implements IEnumerator interface:
class CompaniesEnumerator : IEnumerator {

int index;
ArrayList m_oCompanies;

public CompaniesEnumerator(ArrayList oCompanies) { this.m_oCompanies = oCompanies; }

public bool MoveNext() { return (++index < m_oCompanies.Count); }

public object Current {
get {
if (index < m_oCompanies.Count) return m_oCompanies[index];
else
return null; }
}

public void Reset() { ... }
Nov 20 '05 #1
1 3345
Mike,

The watch window cannot view properties that have an indexer. If you need to
see the contents of an indexed property, specify the index as part of the
watch.

e.g.

m_oCompanies.Item(0)

You'll get an exception if the index you specify is out of range.

On a side note, I didn't know you could compile C# code with VB.net ;) (your
source is c#, but your post refers to VB)

HTH,

Trev.
"Mike" <no****@hotmail.com> wrote in message
news:Ou**************@TK2MSFTNGP10.phx.gbl...

Hi,

I have created a collection of a custom class. Everything works fine (can
add these items in a combo from within a VB.NET application, for instance),
but when looking at the collection from a VB.NET application in the Watch
window, I cannot see the items of the collection. The message in the Watch
window's "value" says: "<cannot view indexed property>." Below is the code I
wrote.

Any idea of what is wrong? Or is the error message "correct"?

Thanks a lot.
Mike


public class Companies : IEnumerable {
ArrayList m_oCompanies = null;

public Companies() { // Nothing is done in the constructor. }
public void Add(Company oCompany) {...}
public Company this[int index] {
get { return (Company)m_oCompanies[index]; }
}
public int Count { ... }
}
public IEnumerator GetEnumerator() { return new
CompaniesEnumerator(m_oCompanies); }
// Inner class implements IEnumerator interface:
class CompaniesEnumerator : IEnumerator {
int index;
ArrayList m_oCompanies;
public CompaniesEnumerator(ArrayList oCompanies) { this.m_oCompanies =
oCompanies; }
public bool MoveNext() { return (++index < m_oCompanies.Count); }
public object Current {
get {
if (index < m_oCompanies.Count) return m_oCompanies[index];
else
return null; }
}
public void Reset() { ... }
Nov 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Mike | last post by:
Hi, I have created a collection of a custom class. Everything works fine (can add these items in a combo from within a VB.NET application, for instance), but when looking at the collection from a...
3
by: Hadar | last post by:
Hi, I'm trying to dynamically set the src of an iframe with the <% %> block: <iframe id="content" src="<% = Request.QueryString.Get("content") %>" width="100%"></iframe> Notice that the tag...
1
by: Ed West | last post by:
Am getting this error with the following code, particularly this line: <%# Check(DataBinder.Eval(Container.DataItem, "broker_id"))%> I am creating checkboxes and the Check function checks to...
1
by: Bill Johnson | last post by:
In vb6 I could quickly go to any given property while in the properties window by holding the CTRL + SHIFT keys down plus the first letter of the property I want to edit. For example, if I wanted...
2
by: Jofio | last post by:
I have 3 files, namely: dArray.h dArray.cp TestdArray.cpp Problem is when I compile the 'main' program - TestdArray.cpp - , it (the compiller) produces the following error: 'Unable to open...
3
by: lm Jr | last post by:
<cc:SourceWindow id="SourceWindow1" FileName="<%=Request.ServerVariables%>" RunAt="server" > The above produces the following error: Server tags cannot contain <% ... %constructs. Any idea,...
0
by: Debajit Adhikary | last post by:
I'm writing a SAX parser using Python and need to parse XML with entity references. <tag>&lt;&gt;</tag> Only the last entity reference gets parsed. Why are startEntity() and endEntity() never...
3
by: AleXmanFree | last post by:
Hi , I have got problem with passing my inline based value to y user control (or custom control, no matter which one I use, I have tried both to make sure it doesnt matter) . So say I have...
2
by: kwokv616 | last post by:
I'm writing some very simple codes that i'm quite sure are correct (at least i can't find out what is wrong with it =P) I'm trying to run the following: ...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.