|
This is done by returning a class from you indexer:
public class Books: CollectionBase<br />
{<br />
public Books()<br />
{<br />
}<br />
<br />
public void Add(Book book)<br />
{<br />
List.Add(book);<br />
}<br />
<br />
public void Remove(Book book)<br />
{<br />
List.Remove(book); <br />
}<br />
<br />
public Book this[int index]<br />
{<br />
get<br />
{<br />
return (Book) List[index];<br />
}<br />
}<br />
}<br />
<br />
public class Book<br />
{<br />
public Book()<br />
{<br />
}<br />
<br />
public void FindInText(String value)<br />
{<br />
<br />
}<br />
<br />
public String name<br />
{<br />
get<br />
{<br />
return "hello, world";<br />
}<br />
}<br />
}
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
10x man for quick answer - It's look very simple now but there's some problem with this code in my program Actually I making program that will be Outlook client (receive e-mails from Inbox,manage them,send, etc...) For this purpose I made an .DLL that will implement all function,properties that I need in my main() program. Generally I read one by one all e-mails in Inbox and return to main() program the properties of this e-mail item. To work with e-mail item I need to know it serial number (number in the list,index..) So I came up with idea how to handle (error traping,return error codes..) e-mail's from my DLL. For this I made function like
String Subject (int eMailIndex)
{
try
{ return this.emailItem.Subject.ToString(); }
catch
{ throw (new System.Exception ("eMail is not found"); }
}
But number of requred function is grow up quickly (like GetSenderName,GetReceivedTime, etc...) and all of them requred just an index (integer) of active e-mail item. So I thought instead sending all the time the integer with the function, make an indexer that will do all the work. The problem is - I don't know how to write this Some function requred just an index some of them requred some parameters to be send with them and not just an index, and I don't have any collection (and don't need it) in my class and nowhere in the program (So I can not work directly with .List[index] ). Can you help me to write such a class that will do this work ? (Don't worry about connection to Outlook - I'll make it myself - just name it with guesible names (like eMailItem) and I'll do all the rest)
P.S. If you know any site that will help me with Outlook programing please send me a link too if you can
|
|
|
|
|
There are a number of solutions
1) An indexer does not have to be a integer - you can use any type of object, so create a class that contains the index of the email and the command you want to execute.
2) Use a standard index to get the email back then add a function to the class for every outlook function.
I prefer the later as its more oo.
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
Hmmm.. always get an error
Compiler Error CS0021
---------------------
Cannot apply indexing with [] to an expression of type 'type'
An attempt was made to access a value through an index operation on a data type that does not support array-like operations.
|
|
|
|
|
post the code so I can see whats wrong.
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
I've loaded an image into a control. Now the User can choose a particular region in the image. Once the user releases the mouse, the entire image has to be zoomed by a specific factor and the scrollbar should be moved to point to the region that the user selected.
Approach: I tried out the followin approach.
I zoomed the entire image and move the horizontal and the vertical scrollbar to the start of the zoomed region.
The problem is: The selected region thats captured corresponds to the original bitmap, but when the image is zoomed the coordinates changes. So is there any way that i can find out the coordinates of the clicked part in the zoomed image.
Any other approach to this problem is also highly appreciated
|
|
|
|
|
Just trying. What if you keep a bitmap object with the original image?
|
|
|
|
|
Hey
I didn't get u. Can u be bit more elaborate. It would be helpful if u could give some sample codes
|
|
|
|
|
either using the scale* on your picture/form or just multiple your coordinates by size.
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
|
Hey guys i was just wonder how i can catch the console output and write it to a text box ? i have been trying to do it via streams. but its to no aval it seems..... does anyone know how ?
Thanks
jesse M
The Code Project Is Your Friend...
|
|
|
|
|
fred.exe > fred.txt
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
I design a webservice with c#,
this webservice have some [WebMethod(EnableSession=true)]'s method
but when I use it with c++,Session lose
why?
thanks, codeproject
|
|
|
|
|
i want to make a text display on a textbox according to what I type in another textbox after I press a button. I am trying to get this to happen on one Main Form several times having the thread stop at each question and then resume after the button is pressed stopping for the next question.I was thinking of using a Thread.Sleep() method but am getting confused pretty quickly being new at programming.
|
|
|
|
|
don't use sleep - it will break your app.
much simpler use a variable with either a number or a enum - this is your state.
every time the use presses the button increate the state and then do which every action is required for that state.
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
Hmmmm,
Say I use XmlDocument to load an XML file off disk, now I cannot call Save on this same file eh? I even tried to call Close on the XmlTextReader used to load the XML but even then it wont let me save to the same file.
THus if I want to edit c:\aaa.xml I need to create c:\aaa1.xml, then del aaa.xml and rename aaa1 to aaa. I dont like this at all.
Anyone knows how to overcome this?
Regards,
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Review by Shog9
Click here for review[NW]
|
|
|
|
|
Just a thought: was the file read-only?
|
|
|
|
|
|
It seems to work, at least with .NET 1.0. The following code does what it is expected to do :
System.Xml.XmlDocument d = new System.Xml.XmlDocument();
d.Load(@"c:\opml.xml");
XmlNodeList elemList = d.GetElementsByTagName("outline");
for (int i=0; i < elemList.Count; i++)
elemList[i].Attributes.Append( d.CreateAttribute("myattrib") );
d.Save(@"c:\opml.xml");
|
|
|
|
|
|
Does somebody know how to assign and build key accelerators using C#?
Or does someone know how to activate these accelerators in C++?
|
|
|
|
|
Dear reader,
I want to write a program wich will be used as some kind of MSN-like tool to chat with other users of my LAN. Does anyone know how to build such applications using C++, Java or C#?
I think it can be done using IP-numbers!
Thank you in advance
|
|
|
|
|
There are lots of chat program sample in this site for both C++ and C#. I guess they can help you.
Mazy
"And the carpet needs a haircut, and the spotlight looks like a prison break
And the telephone's out of cigarettes, and the balcony is on the make
And the piano has been drinking, the piano has been drinking...not me...not me-Tom Waits
|
|
|
|
|
Hi, to build a LAN chat software is not a problem, but to analyze what you want it to do is the main thing. You can contact me for more details about this dennisroy.glofleet@gmail.com. This will be done with C# using the UDP functionality.
|
|
|
|
|
I need to write a program which uses 2 forms, one for the standard interface, and one for advanced options.
I can't write a program which asks for some information in the second form, and then passes it to the first form. I've declared the 2nd form in the first one.
How can I build a program with those two cooperating forms?
Thank you in advance,
Boudewijn Ector
|
|
|
|