Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Listview with imagelist problem

Status
Not open for further replies.

dotnetguy

Programmer
Apr 13, 2005
7
US
Hi All,
I am having problem with listview and imagelist.

I loaded some images into imagelist and i am assigning it to listview in runtime.

well here user has two options
he can view the data in listview with images and without images.

I am able to do that.
by removing images from the imagelist.

but when I removes images, the space earlier occupied by image is remains same but here I need to make text alignment to left when i removes images from the imagelist.

any help would be highly appreciated

Thanks
dotnetguy
 
Rather than removing images from the ImageList, does removing the ImageList from the ListView work?

Code:
//Initialized elsehwere
ListView lvw;

lvw.SmallImageList = null;
lvw.LargeImageList = null;
 
Hi Dalchri,

I did that, even I am unable to clear that space which was earlier occupied by images


Thanks
Dotnetguy
 
Hi Dalchri,
here I am pasting piece of code,
Plz have a look,

still I was getting space

//to show images with text

private void button1_Click(object sender, System.EventArgs e)
{
//listView1.Items.Clear();
//listView1.SmallImageList=null;

listView1.Clear();
this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader1,
this.columnHeader2});


this.listView1.SmallImageList = this.imageList1;



System.Windows.Forms.ListViewItem listViewItem1 = new System.Windows.Forms.ListViewItem(new string[] {
"Aadi",
"Tanneeru"},0);
System.Windows.Forms.ListViewItem listViewItem2 = new System.Windows.Forms.ListViewItem(new string[] {
"Aadi",
"Tanneeru"},1 );
this.listView1.Items.AddRange(new System.Windows.Forms.ListViewItem[] {
listViewItem1,
listViewItem2});

}


//to show just text
this.listView1.SmallImageList = null;
this.listView1.LargeImageList=null;
listView1.Clear();
this.listView1.Items.Clear();
// this.imageList1.Images.Clear();

// this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
// this.columnHeader1,
// this.columnHeader2});

listView1.Columns.Add("First Name",100,HorizontalAlignment.Left);
listView1.Columns.Add("Last Name",100,HorizontalAlignment.Left);


// System.Windows.Forms.ListViewItem listViewItem1 = new System.Windows.Forms.ListViewItem(new string[] {
// "Aadi",
// "Tanneeru"});
// System.Windows.Forms.ListViewItem listViewItem2 = new System.Windows.Forms.ListViewItem(new string[] {
// "Aadi",
//
// "Tanneeru"});
//
ListViewItem lv1=new ListViewItem("Aadi");
ListViewItem lv2=new ListViewItem("Tanneeru");
lv1.SubItems.Add("Tanneeru");
lv2.SubItems.Add("Aadi");
listView1.View=View.Details;

listView1.Items.Add(lv1);
listView1.Items.Add(lv2);

}

Thanks
Dot
 
did you try calling the ListView.Refresh() method to force a repaint?
 
Tan,

this could be a dumb question, but could you not put the image in a separate column, and if they click to not view the images, just set the column width to 0?

Good luck,
Kevin

- "The truth hurts, maybe not as much as jumping on a bicycle with no seat, but it hurts.
 
Hello Kevin,
if I set column width to 0, I wont be able to see the data in first colum, bcos Ive image and data in first column .

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top