473,401 Members | 2,139 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,401 software developers and data experts.

Indexer does not show

Hi,

I built a user control myPanel derived from the Panel
class.
In myPanel I added code for an indexer which looks like
this:

private Color[] mColor = new Color[10];
[IndexerName("Colors")]
public Color this [int i]
{
get
{
if (i < 0 || i >= 10)
return Color.Empty;
else
return mColor[i];
}
set
{
if (i < 0 || i >= 10)
// Do nothing
else
{
mColor[i] = value;
}
}
}

I also added some properties that are not indexed.

When I add myPanel to a form, I see all the properties
that I added in the property window, but I don't see the
indexer.

What did I do wrong?
Can anybody help me with this, please?

Thanx a lot!

Vera

Nov 15 '05 #1
2 1386
Vera wrote:
Can anybody help me with this, please?


http://www.codeproject.com/cs/miscct...ectiondata.asp

--
There are 10 kinds of people. Those who understand binary and those who
don't.

http://code.acadx.com
(Pull the pin to reply)
Nov 15 '05 #2
If you are looking for the indexer in the Intellisense list, you probably
will not see it. The indexer in C# is not handed by a direct call to a
property but rather the index notation ([...]). The name that you gave it,
I believe, is for languages that do not support the index notation such as
VB.
"Vera" <an*******@discussions.microsoft.com> wrote in message
news:05****************************@phx.gbl...
Hi,

I built a user control myPanel derived from the Panel
class.
In myPanel I added code for an indexer which looks like
this:

private Color[] mColor = new Color[10];
[IndexerName("Colors")]
public Color this [int i]
{
get
{
if (i < 0 || i >= 10)
return Color.Empty;
else
return mColor[i];
}
set
{
if (i < 0 || i >= 10)
// Do nothing
else
{
mColor[i] = value;
}
}
}

I also added some properties that are not indexed.

When I add myPanel to a form, I see all the properties
that I added in the property window, but I don't see the
indexer.

What did I do wrong?
Can anybody help me with this, please?

Thanx a lot!

Vera

Nov 15 '05 #3

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

Similar topics

14
by: Nikhil Patel | last post by:
Hi all, Is it possible to have more than one indexer in a class. If not, are there any good alternative ways to achieve similar functionality. Thanks... -Nikhil
0
by: Brian Takita | last post by:
Hello, I am able to test an object to see if it is an indexer (IsIndexer function), however I don't know how to call the indexer without Unboxing to the object's class. Do I need to use...
1
by: Dotnetjunky | last post by:
Hi all Is it correct that there's a link between indexer and Items property in C# ? If yes, please show me what is it ? thanks in advance. -- Dotnetjunky
1
by: Iulian Ionescu | last post by:
I have the following problem. I derived a class from ArrayList to provide some additional events I need. Then I derived 2 different classes from this one and each of them defines an indexer that...
2
by: Jerry Negrelli | last post by:
I'm trying to define a custom class indexer to take the place of an underlying Hashtable member so that values can be referred to as Class1 instead of Class1.someVar. The following code does...
7
by: Oren | last post by:
hi I have created a class with a simple indexer what is the syntax for adding the function "Remove" ... myClass.colors=Color.Black; // WORKS O myClass.colors.Remove(); // ?? .......
4
by: Geordie | last post by:
Hi, I'm in the process of converting a production VS 2003 application to VS 2005. To simplify the conversion I'm converting a small piece at a time and then unit testing the code to confirm it...
3
by: Duggi | last post by:
Hello, I have a class with an indexer in the class. The code code is in C#. However I was trying to access the indexer in the other lang of .Net, VB. I ran into some indexer related issues (I...
2
sagacious
by: sagacious | last post by:
Hello TO All.. It Been Just Some Years That I Have Worked With WML, Html, Php, Css, Ajax And My SQL.. Now New Entered in Perl, Python ; World... I Have 2 Search Engine Script Which Starts...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.