473,748 Members | 2,239 Online
Bytes | Software Development & Data Engineering Community
+ 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.AddRan ge 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 3293
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.AddRan ge 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 listviewsubitem s.

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******** ******@TK2MSFTN GP10.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
4756
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 that displays items in a ListView control that is running on a Windows 98 SE machine. The machine is well within system specifications for the .Net Framework. It is a 600 MHz with 128 MB of RAM, and also has the Resource Meter application installed....
5
1709
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 objects in the ArrayList. I have also added column sorting, when a user clicks a column. All that works fine. But when a user double clicks a line in the listview (detail mode), an event
7
15002
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 MyList data is resident in a dataset table. I'm stuck and can't choose either because. If I choose ListView as my control I don't understand how to programmatically get the data from the dataset table
12
3127
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 control in code and add it to the form, it works. Why don't the items show up in the ListView that I added at desgn time. ' Create three items and three sets of subitems for each item. Dim item1 As New ListViewItem("item1", 0) ' Place a check...
4
10694
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 hearder..) Thanks for any help !
2
6726
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 "Activity" in a listview the date fields is displayed like : dd.mm.yy 00:00:00. How can i format this date. I do not want the time. Just the date. In my dataset "activity" all date fields are formatted as: dd.mm.yyyy. Why do i get the 00:00:00 ??...
4
6093
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 with the native ListView to display various datasets in VirtualMode. I have a ListView with the VirtualListSize set and the appropriate columns in place which is all similar to the old VB6 app. However, the similarities end there as I can't find...
2
1875
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 it seems like ListView only allows texts. I guess if I can only know the exact bounds of the columns, I could overlay other Windows controls on it making the simmilar effects. But the problem is I can't know the exact amount of change when the...
3
2215
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 characters. Is there a way to increase this? Thanks
0
8991
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9544
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9372
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9324
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9247
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8243
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6796
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4874
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3313
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 we have to send another system

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.