Help with ListView

D

David Elliott

I am trying to get data from a CollectionBase derived class into a ListView.
Currently the output is one continuous line of data that is of Boolean type
e.g. True True False True False False False True .

No other data or header information is displayed.



public class RecFormCtxSaved
{
private Boolean enabled;
private Boolean selected;
private string column;
private string text;
}

private void createListView()
{
ListViewItem lvi;

this.listView1.Columns.Add("Enable", 50, HorizontalAlignment.Left);
this.listView1.Columns.Add("Select", 50, HorizontalAlignment.Left);
this.listView1.Columns.Add("Column", 50, HorizontalAlignment.Left);
this.listView1.Columns.Add("Text", 50, HorizontalAlignment.Left);

foreach (RecFormCtxSaved rec in coll)
{
lvi = new ListViewItem();
lvi.Text = rec.Enabled.ToString();
lvi.SubItems.Add(rec.Selected.ToString());
lvi.SubItems.Add(rec.Column);
lvi.SubItems.Add(rec.Text);
this.listView1.Items.Add(lvi);
}
}
 
D

Deepak Kapoor

Hi David,
You should set the View property of your ListBox to Details.


Deepak

#*#*#*#*#*#*#*#*#*#*#*#
I Code therefore I am
 
D

David Elliott

Thanks...

Any idea on how to change the text of True to a check mark and False to blank?
 
D

Deepak Kapoor

This is what you can do
set listView1.CheckBoxes = true;
this will display a check box

now do a if condition

if(listView1.Items[0].Text == "true")
listView1.Items[0].Checked = true;
else
listView1.Items[0].Checked = false;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top