|
MSDN[^]
It takes a string or a ListViewItem. Create your own class inheritting from ListViewItem and do the manipulation you require in there. When returning an Item(s) just cast it to your class type and any extra properties/methods etc will be available.
Dave
|
|
|
|
|
Hi Guy
I think Listview directlly not support add object.You one option to do this, create a own object with inherit in ListViewItem,add ur a collection or any other kind of list. after add to that listViewItem into ListView.
i hope this is help to u.
Thanks
Cheers
RRave
MCTS,MCPD
|
|
|
|
|
Something like what DaveyM69 suggested. SIX hours ago.
only two letters away from being an asset
|
|
|
|
|
I have had to, on a number of occasions, do something like the following:
switch (a.GetType().FullName) {
case "System.Int32":
...
break;
case "MyNamespace.SubNamespace.MyClass":
...
break;
...
} The problem is that if I change class name or the namespace of MyClass, the above breaks without generating a compile-time error. The way that I would like to perform the above is by using the type itself, and have "case typeof(MyClass):", but that DOES generate a compile-time error. I am wondering, then, if there is some method like typeof that gets a constant string representing the class name at compile time, so I could change the above code to...
switch (a.GetType().FullName) {
case nameof(int):
...
break;
case nameof(MyClass):
...
break;
...
} This way, I would get compile-time errors instead of run-time errors if I changed the classname but didn't update the above code. Thanks,
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
switch cases take constants so you can't call a function in a switch case, so you'll use if statements
if (a.GetType() == typeof(Int32))<br />
...<br />
else if (a.GetType() == typeof(MyClass))<br />
...
Eslam Afifi
|
|
|
|
|
Hi Guys
this is correct way when we are compare own object or own defiened class object with runtime. typeof keyword is very very useful.
Thanks
Cheers
RRave
MCTS,MCPD
|
|
|
|
|
I just want to add that this code provide direct type comparison. If you want to compare the inheritance hierarchy use the is keyword as Luc Pattyn mentioned here.
Eslam Afifi
|
|
|
|
|
1. You can use if-else/if statements, instead of a switch
2. Or you may be able to use:
case typeof(MyClass).FullName:
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
Once you start relying on the fully qualified name of your class as a string value in another class or application they are pretty much bound to one another.
only two letters away from being an asset
|
|
|
|
|
Hi Jeff,
you should try not to rely on type names, since doing so will fail for derived types.
The way to go most often is using the "is" or "as" keywords, as in:
if (obj is Font) {
... do someting fonty (probably will need a cast)
} else if (obj is Panel) {
... deal with a Panel (probably will need a cast)
} etc.
or
Font fnt=obj as Font;
if (fnt!=null) {
... do someting fonty to fnt (no extra cast required)
}
Panel pan=obj as Panel;
if (pan!=null) {
...
}
The above will also match mySpecialPanel and the like, something typename-dependent code
would typically not do.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
You could also use some lookup pattern.
setup type -> action association
Dictionary<type, somedelegate> myLookup = new .....
myLookup.Add(typeof(string) , () => MessageBox.Show("Its a string!"));
myLookup.Add(typeof(int) , () => Console.WriteLine("ooh an int.."));
and then replace your switch/if with:
------
SomeDelegate action;
if (myLookup.TryGetValue( a.GetType() , out action ) )
{
action();
} ----
So you replace your switch/if completely with the lines above...
But it depends on what you actually want to accomplish.
See the post above mine regarding subclasses.
|
|
|
|
|
hi ,
i've defined a class named vector that it includes two Points and one void for drawing that and ..., i just want to know how can i find the angle between two vectors that start from one point?,
does anyone know know it's code (for C#)
|
|
|
|
|
Did you try searching Google? First find out formula for finding the angle and then write corresponding c# code.
|
|
|
|
|
|
You mean this?
Y1 Y2
| /
| /
| /
| /
|α/
X
You want to find the angle Α between vector Y1 and Y2?
If so convert the points to vectors (like you said) and subtract the angles, then you have the angel between the points.
α = Y1∠θ - Y2∠θ
If you mean you have something like this:
Y1_________________________________________Y2
\ /
\ /
\ /
\ /
\_________________________________/
Y3 Y4
X
Where you are looking for a part of the circle (the lines between Y1,Y2 and Y3,Y4 are arcs from the circle drawn from radius from circle( (Y1)∠θ ) - circle ( (Y3)∠θ ) sectioned between Y1∠θ and Y2∠θ
|
|
|
|
|
Hello,
I have some gawk scripts that i want to run in C# code.
Is it possible?
|
|
|
|
|
You can achieve the same goal using Regular Expressions. But this would mean rewriting those gawk scripts.
Just because we can; does not mean we should.
|
|
|
|
|
Greet to all
I am facing problem in accessing data of ms word to my project of c sharp .net 2005
I want to access the data word wise so that I can put it in Sql table
hoping for the good reply from you all
thanks
|
|
|
|
|
You can use Word Object Model to get the data from ms word document
|
|
|
|
|
|
|
|
thanks but I don't want to install another word package apose.word
But yes thanks
|
|
|
|
|
welcome.i think frist link help to u
Cheers
RRave
MCTS,MCPD
|
|
|
|
|
Sorry for bother so I change my question please tell me
where can I find some speech recognition classes or how do I use a specific class to recognize speech.Keep in mind i am working with visual c#.net2005.
|
|
|
|