|
How to delete or Remove Item with image from ListView in C#?
I am creating a ListView and setting a LargeImageItem. I am adding each item of string and index of the image. I also adding image to LargeImageList. Here is the code snippet in C#.NET
ListView lstView = null;
String fileName;
int index = 0;
private void addImage(filename, index){
lstView.Items.Add(fileName, index);
lstView.LargeImageList.Images.Add(Image.FromFile(fileName));
...
}
Now I want to remove item from the ListView. Here is sample code.
private void removeImage(index){
lstView.LargeImageList.Images[index].Dispose(); -----line 1
lstView.LargeImageList.Images.RemoveAt(index); -----line 2
lstView.Items[index].Remove(); --line 3
//lstView.Items.RemoveAt(index); --line 4
lstView.Invalidate();
...
}
If I use line 1,2,3 then if I try to delete 3rd image out of 5 image item in the list then it deletes 3rd image also deletes last image. If I use only line 3 or 4 then while deleting it works fine but if I add another image then it keeps the old image list pattern no matter which image I add.
Does anyone come across this problem? If anyone knows better idea, How to delete ListView item with image associated? And also able to add item after wards.
Hope it is interesting problem.
Thanks in advance
- Sudhakar
|
|
|
|
|
i've created a class having as private member a picturebox and a label.
I use this new object created in my application:
public class myObj
{
public Label mLabel = new Label();
public PictureBox mPictureBox = new PictureBox();
public myObj(Points myPoint)
{
....
myObj mObj = new myObj(lPoints); // set x, y of this new object
now i want add this to my form ( by this.controls.add(...) ) but i can't because it is not a control, how can i do?
|
|
|
|
|
You can't add it to the controls collection because your class doesn't inherit from Control. Since your just encapsulating normal Windows Forms controls, rewrite your class inheriting from UserControl. THen you'll be able to add it to the Controls collection.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I am used to VB.NET so this might be something stupid, but I can't seem to find a way to add System.Collection in C#.net after right clicking the references folder and selecting "add reference". I am trying to use a hash table but need the reference.
Thanks for the help
|
|
|
|
|
I believe it's there already, have you tried to just use it ?
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
hmm, maybe I should try Ya I did try silly. For some reason on my home machine it is readily available. On the other machine it threw an error saying that it had to be referenced, but it was no where in the reference library.
|
|
|
|
|
According to MSDN, it's in Assembly: Mscorlib (in Mscorlib.dll).
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Does anybody have sample code for using SSH/Telnet with the Sockets class (without purchasing a control)?
|
|
|
|
|
ok ... i am trying to create Custom Control (which later can be added to VS.NET tool box and added to any windows form). This custom control contains a data-grid. I want to implement the following functionality :
when user resizes this custom control he/she should be able to see control (i.e., data grid) resizing, like in the case of typical/intrinsic controls (text box). when we resize them ... we can see them their size changes.
second thing i want to do is that : as soon as this control is added to a windows form, a wizard is launched which allows customization.
i don't know how to implement this behavior... and where should i start?
any suggestions
|
|
|
|
|
How can i detect if a user has double-clicked the caption bar of a form (which normally causes the window to maximize)?
And is there a way to add icons in the upper left corner (left from the quit, maximize and minimize boxes)?
|
|
|
|
|
Okay I found the answer for my first question.
|
|
|
|
|
|
|
I used the WM_NCLBUTTONDBLCLK Event
|
|
|
|
|
In this way i create a class inherited from PictureBox, but if i want that it inherit also from Label class what i have to write?
public class MyClass : PictureBox
{
...
|
|
|
|
|
|
You could use interfaces.. But you prolly need more then just a definition of members..
|
|
|
|
|
Im wishing to view all of the files in a document library in a tree view format. How can I do this? I have not found any controls at all in the API to assist me in my cause.
Sincerely,
Jim
|
|
|
|
|
Hi
I would like to ask if there is any lib, comercial or not, that allow me play sound (async and sync) in .Net compact framwork in a managed way?
regards
Leonardo Paneque
WEBOO Group
University of Havana
|
|
|
|
|
Ok.. i want to remove the side header (well.. where cursor appears to indicate the selected row) from the data grid control.... is there any way to remove it or is there any way to reduce it's width... if you don't understand what i mean... please email me i will forward you the pic.
thanx in advance
|
|
|
|
|
ronin,
I think what you are refering to is called the "Row Selector" or "Record Selector". If you are using Microsoft's built-in control, I do not think there is a way to this. Some 3rd party controls allow for this flexability but of course they cost money. Hopefully, Microsoft will add this in for VS2005.
Joel Parmer
Black holes are when GOD divides by zero.
|
|
|
|
|
|
Hello:
From JavaScript I need to execute a function write in C#.
I have not found the way to do it not using __doPostBack, but problem is that using __doPostBack is generating a post back event from a script that is into a link button.
I’d like to see the way to execute a function write in C# from JavaScript avoiding a post back.
If somebody knows how to attain it, I Hill thank very much.
A.L.
El Hombre que tiene Amigos ha de mostrarse Amigo...
|
|
|
|
|
That simply is not possible. Javascript executes on the client, ASP.NET code on the server. You can work around that by opening a new window and posting contents to the server using that window.
Regards
Senthil
|
|
|
|
|
If you were trying to call into a .NET Framework control hosted on the client machine, then, yes, it is possible to do COM Interop between Java and a C# control.
But calling a method on the server? Only if it was part of a Web Service could you do this from JavaScript. You can't call an ASP.NET control or code, server-side, from client-side JavaScript without doing a postback.
BTW, this question really belongs in the ASP.NET Forum. It has nothing to do with C#, even if you wrote your ASP.NET pages with it.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|