473,473 Members | 2,166 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

ListView columns in detail mode

Greetings!

I am attempting to display data in tabular form using a ListView control in
detail mode. This is for a program I originally wrote in VB6. In VB6, I
would add an item to the ListView, and the item would automatically have the
correct number of subitems, which I could access using array syntax. That
doesn't seem to be the case in VB .Net. I tried creating a two-column
listview. I added an item, and then tried to set the first subitem's text.
I expected that the text I supplied for the item would appear in the first
column and the text for subitem 0 would appear in the second column. That's
what would have happened in VB6. It didn't. The text for the item appeared
in the first column, but text for subitem 0 overwrote the first column, and
the second column remained empty. If I used SubItems.Add, I would get what
I wanted.

But what if I don't want to fill in all columns? In VB6, I automatically
had the correct number of subitems, and I could fill in columns 1, 2, 5, 6
and 7 and leave the rest blank. In .Net, I have to add a subitem for all of
the columns, even if I'm not going to be using them for that particular row.
The only way I can think of to do that is to use build an array of empty
strings of the correct size and use SubItems.AddRange or Item's constructor
that accepts a string array to pre-build my subitems. Why doesn't the
ListView control automatically give me the correct number of subitems for an
item, since it knows how many columns I have?

Thanks very much!

Rob
Nov 20 '05 #1
3 3265
Cor
Hi Rob,

This is a VB.net newsgroup, I read a lot in your message what you should do
in VB6.

But what is what you want to archieve with the listview in VB.net, that is
for most of us much easier to answer.

I do not know one control which is exactly the same in VB6 as in VB.net even
not the label.

Cor
I am attempting to display data in tabular form using a ListView control in detail mode. This is for a program I originally wrote in VB6. In VB6, I
would add an item to the ListView, and the item would automatically have the correct number of subitems, which I could access using array syntax. That
doesn't seem to be the case in VB .Net. I tried creating a two-column
listview. I added an item, and then tried to set the first subitem's text. I expected that the text I supplied for the item would appear in the first
column and the text for subitem 0 would appear in the second column. That's what would have happened in VB6. It didn't. The text for the item appeared in the first column, but text for subitem 0 overwrote the first column, and the second column remained empty. If I used SubItems.Add, I would get what I wanted.

But what if I don't want to fill in all columns? In VB6, I automatically
had the correct number of subitems, and I could fill in columns 1, 2, 5, 6
and 7 and leave the rest blank. In .Net, I have to add a subitem for all of the columns, even if I'm not going to be using them for that particular row. The only way I can think of to do that is to use build an array of empty
strings of the correct size and use SubItems.AddRange or Item's constructor that accepts a string array to pre-build my subitems. Why doesn't the
ListView control automatically give me the correct number of subitems for an item, since it knows how many columns I have?

Nov 20 '05 #2
Cor,

Thank you for your reply. Yes, I know this group is for VB .Net. So, the
question remains: When I create a ListView control in detail mode with a
certain number of columns, does it automatically give me the correct number
of subitems? It doesn't seem to, and I don't understand why not, since VB
..Net knows how many columns I created in it. If not, what is the preferred
way to create the subitems I will need?

Thank you very much.

Rob
Nov 20 '05 #3
Cor
Hi Rob,

First of all, I think there is no preferred way in vb.Net.

Maybe there are some unpreferred.

A lot of things in VB.net (or better in the framework) are made of parts,

We see it everytime back in a lot of on first sigth totally different
things.

The listview can holds references to a listviewitems a seperate class and a
the listviewitem can holds by instance an image and listviewsubitems.

When you are creating items, rembember that you have everytime to create an
item or a subitem and than you can add, insert, remove and removeat that
item to/from a higher level.

Another point of watch for is that the listview has 4 viewstates the same as
explorer.

Here is a link on msdn, that gives the members of the listviewsubitem.

http://msdn.microsoft.com/library/de...mberstopic.asp
I hope this helps a little bit.

Cor
"Rob Richardson" <th*****@n2net.net> schreef in bericht
news:eK**************@TK2MSFTNGP10.phx.gbl...
Cor,

Thank you for your reply. Yes, I know this group is for VB .Net. So, the
question remains: When I create a ListView control in detail mode with a
certain number of columns, does it automatically give me the correct number of subitems? It doesn't seem to, and I don't understand why not, since VB
.Net knows how many columns I created in it. If not, what is the preferred way to create the subitems I will need?

Thank you very much.

Rob

Nov 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: David Miller | last post by:
Hello, I posted this to DotNet.Framework.Controls a week ago or so and got no response, so now I will repost it here to see if anyone here knows anything about it... I have an application...
5
by: Søren Reinke | last post by:
Hi everyone. In a little program i am writing i have a listview, i fill it with data from an ArrayList which contains a lot of objects. The data for the columns are differente fields in the...
7
by: BobAchgill | last post by:
I am trying to decide which of these controls to use to implement letting my user select a full row from MyList. The MyList has several columns which would be nice to sort by at run time. The...
12
by: Dennis | last post by:
I have a form which has a ListView control named ListView1 added at design time. When I add items using the following code, they don't appear in the list view. However, if I create a ListView...
4
by: Steph. | last post by:
I have a List view displaying data in Detail mode with several columns. How I can get the column index the user clicked on ? (when user click on an item inside the ListView, not on a column...
2
by: Lars Erik Nes | last post by:
Hi all. I have a problem. I get all my data from a dataset (not mssql) and in that dataset i have a table called "Activity". In this table i have a few date fields. When i display the dataset...
4
by: gene kelley | last post by:
I had a VB6 app that used a third party ListView control to simply display various recordsets. The control had a VirtualMode which I used for this display. Now in VB2005, I want to do the same...
2
by: Sin Jeong-hun | last post by:
I often use detail view of the ListView control to display tabular data (is there any better way?) Many real-world applications display buttons, progress bars or dropdown lists in the columns, but...
3
by: NvrBst | last post by:
I have ListView in Detail Mode and the length of each item is cut off at 259 characters. The "listView1.Items.Text" contains the entire string, however, just the display is truncated at 259...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.