Click here to Skip to main content
15,921,643 members
Home / Discussions / C#
   

C#

 
Generalcheckbox in DataGrid Pin
ppp00114-Feb-05 15:38
ppp00114-Feb-05 15:38 
Questionhow to select a line on DataGrid Pin
yu-yu14-Feb-05 14:48
yu-yu14-Feb-05 14:48 
Questionhow to debug exchange store event sink Pin
muh22m14-Feb-05 14:30
muh22m14-Feb-05 14:30 
Questioncan you convert this? Pin
jedskie_a14-Feb-05 13:47
jedskie_a14-Feb-05 13:47 
AnswerRe: can you convert this? Pin
Christian Graus14-Feb-05 14:08
protectorChristian Graus14-Feb-05 14:08 
GeneralRe: can you convert this? Pin
jedskie_a14-Feb-05 22:41
jedskie_a14-Feb-05 22:41 
GeneralRe: can you convert this? Pin
Christian Graus15-Feb-05 9:22
protectorChristian Graus15-Feb-05 9:22 
QuestionHow to delete or Remove Item with image from ListView in C#? Pin
SudhaMakki14-Feb-05 11:52
SudhaMakki14-Feb-05 11:52 
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



Generalalmost custom control Pin
Sasuko14-Feb-05 11:47
Sasuko14-Feb-05 11:47 
GeneralRe: almost custom control Pin
Dave Kreskowiak14-Feb-05 17:55
mveDave Kreskowiak14-Feb-05 17:55 
Generalcan't add reference for hash tables in C#.net Pin
kowplunk14-Feb-05 11:45
kowplunk14-Feb-05 11:45 
GeneralRe: can't add reference for hash tables in C#.net Pin
Christian Graus14-Feb-05 12:05
protectorChristian Graus14-Feb-05 12:05 
GeneralRe: can't add reference for hash tables in C#.net Pin
kowplunk14-Feb-05 18:12
kowplunk14-Feb-05 18:12 
GeneralRe: can't add reference for hash tables in C#.net Pin
Christian Graus15-Feb-05 9:21
protectorChristian Graus15-Feb-05 9:21 
GeneralSSH and Sockets Pin
montew14-Feb-05 11:38
montew14-Feb-05 11:38 
GeneralCustom Control Pin
ronin177014-Feb-05 9:44
ronin177014-Feb-05 9:44 
GeneralCaption Bar Pin
TyronX14-Feb-05 9:41
TyronX14-Feb-05 9:41 
GeneralRe: Caption Bar Pin
TyronX14-Feb-05 9:57
TyronX14-Feb-05 9:57 
GeneralRe: Caption Bar Pin
Sasuko14-Feb-05 11:48
Sasuko14-Feb-05 11:48 
GeneralRe: Caption Bar Pin
leppie14-Feb-05 21:41
leppie14-Feb-05 21:41 
GeneralRe: Caption Bar Pin
TyronX15-Feb-05 4:47
TyronX15-Feb-05 4:47 
Questionhow create a class with multi inheritance Pin
Sasuko14-Feb-05 9:19
Sasuko14-Feb-05 9:19 
AnswerRe: how create a class with multi inheritance Pin
Michael P Butler14-Feb-05 9:26
Michael P Butler14-Feb-05 9:26 
GeneralRe: how create a class with multi inheritance Pin
tpepels14-Feb-05 11:49
tpepels14-Feb-05 11:49 
GeneralSharepoint tree view Pin
Esmo200014-Feb-05 9:12
Esmo200014-Feb-05 9:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.