ListView Multicolumn

  • Thread starter Thread starter Rob
  • Start date Start date
R

Rob

VS 2005

How can you tell if a value is contained in a specific column (let's say
column 1 named Status) of a ListView ?

In a list box you could go...

If ListBox1.Items.Contains(strWhatever) then

How would you accomplish this using a ListView ?
 
Rob said:
VS 2005

How can you tell if a value is contained in a specific column (let's say
column 1 named Status) of a ListView ?

In a list box you could go...

If ListBox1.Items.Contains(strWhatever) then

How would you accomplish this using a ListView ?

Wouldn't that be off of subitem? It's been a log time since I worked with a
ListView.

I think each subitem represents data in a column.
 
Yes, I think it goes like this...

MsgBox(ListView1.Items(intCount).SubItems(0).Text)
MsgBox(ListView1.Items(intCount).SubItems(1).Text)

Thanks,
Rob
 
Rob,

As platinumBay you already showed, try to work with the data and not with
the controls as it is direct by a user typed in data.

Cor
 
I am working on a program that has many user defined controls within
flowlayout panels within tab controls....

I need a control that keeps track of each of these user defined controls and
their status. Only one user control may be "active" within a given flow
layout panel within a tab control. So in the unbound list view I keep a
"primary key" of the individual user control, as well as its status (2
separate columns).

When perfoming actions that change status, I iterate thru the list view to
make status changes.

I have figured out how to access the data now.

Is there a better way to do this ?

Thanks
 
Rob,

There are non binded controls, simple databinded controls (textbox etc),
complex databind controls combobox, datagrid etc.

Try the later for database work.

A listview is fore non database work. In fact it exist from endless
collections, keep in mind that the first column is very much different from
all the others. A listview has as well more ways it can be showed however
always with the first column on top. (it is just an older version of windows
explorer).

http://www.vb-tips.com/dbpages.aspx?ID=60e4cbe5-1097-44d0-8560-a31addde6d2c

Here a sample we have more samples. Have a look as well to the treeview
because that is very much simular.

Cor
 
Thanks Cor,

But I think my question remains... Is using a non-bound ListView a good
control to use for keeping track of "active" controls in the situation I
present below ?

The scenario...
I need a control that keeps track of each of these user defined controls
and their status. Only one user control may be "active" within a given
flow layout panel within a tab control. So in the unbound list view I
keep a "primary key" of the individual user control, as well as its status
(2 separate columns).

Rob
 
Steve,

Hmmm...

This is a windows app. What is the specific downside of using a list view
for this ?

Basically, imagine a user control that has a Start and Stop button on it.
There could be 10 of these user controls sitting in a flow layout panel
inside of a tab control. Only 1 of these controls can have a Start button
"active" at any one point in time. Clicking a Start button on one of the
other 10 user controls "stops" the previously "started" user control and
activates the currently chosen user control.

Now that I think about it... I may be able to iterate thru all the controls
except for the chosen "Started" control and stop them without having to
update the List view.

Anyway... it is not necessarily a matter of viewing only one control at a
time. I did not make that clear.

Thanks for your input,

Rob
 
Rob,

I am not sure what you are doing. However if you want to keep track on form,
I would certainly look at that treeview. On the form the controls are mostly
build up to as a tree. If it is just in memory, than you have to explain
more, but certainly a control is than the worst solution.

Cor
 
Cor,

I would like to know "why" it is bad....

Maybe I am missing something, but as I open up new forms and user controls,
it becomes hard to know what the state of the control is in another location
(user control on a flow layout panel on a tab on another form)... the list
view has been set-up as a "Public Property" and is therefore accessible...

Thanks,
Rob
 
Back
Top