473,748 Members | 9,416 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ListView Control access

Joe
I set up two columns in listview.

I use Add to add items, but how do I access the second column? and add text?


Feb 4 '06 #1
1 2039
Hello Joe,

// Create a new ListView control.
ListView listView1 = new ListView();
listView1.Bound s = new Rectangle(new Point(10, 10), new Size(300,
200));

// Set the view to show details.
listView1.View = View.Details;
// Allow the user to edit item text.
listView1.Label Edit = true;
// Allow the user to rearrange columns.
listView1.Allow ColumnReorder = true;
// Display check boxes.
listView1.Check Boxes = true;
// Select the item and subitems when selection is made.
listView1.FullR owSelect = true;
// Display grid lines.
listView1.GridL ines = true;
// Sort the items in the list in ascending order.
listView1.Sorti ng = SortOrder.Ascen ding;

// Create three items and three sets of subitems for each item.
ListViewItem item1 = new ListViewItem("i tem1", 0);
// Place a check mark next to the item.
item1.Checked = true;
item1.SubItems. Add("1");
item1.SubItems. Add("2");
item1.SubItems. Add("3");
ListViewItem item2 = new ListViewItem("i tem2", 1);
item2.SubItems. Add("4");
item2.SubItems. Add("5");
item2.SubItems. Add("6");
ListViewItem item3 = new ListViewItem("i tem3", 0);
// Place a check mark next to the item.
item3.Checked = true;
item3.SubItems. Add("7");
item3.SubItems. Add("8");
item3.SubItems. Add("9");

// Create columns for the items and subitems.
listView1.Colum ns.Add("Item Column", -2, HorizontalAlign ment.Left);
listView1.Colum ns.Add("Column 2", -2, HorizontalAlign ment.Left);
listView1.Colum ns.Add("Column 3", -2, HorizontalAlign ment.Left);
listView1.Colum ns.Add("Column 4", -2, HorizontalAlign ment.Center);

//Add the items to the ListView.
listView1.Items .AddRange(new ListViewItem[] { item1, item2, item3
});

this.Controls.A dd(listView1);

J> I set up two columns in listview.
J>
J> I use Add to add items, but how do I access the second column? and
J> add text?
J>
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
Feb 4 '06 #2

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

Similar topics

3
2854
by: spawn666948 | last post by:
Hey, Everyone I can't seem to get the ListView to work on my Access 2000. I inserted the MS ListView Control. Let's call it "LV" for short. The, the Reference, MS Windows Common Controls 6.0 (SP6), is automatically added. The problem is when I go into code and type "me.LV.", the proper dropdowns don't appear. I'm expecting to see ".ListItems.", ".ColumnHeaders.", etc. But, instead I see, ".about.", ".application." For the life of...
1
5965
by: Welie | last post by:
Hi all- I am using a listview (MSComctlLib.ListViewCtrl.2)on an Access form. Actually there are six listviews on the form. I need to do the same thing to all six forms so I have the loop below. I would like to assign each control to a listview object, however I get a type mismatch. Further investigation reveals that the type of the control is "Custom Control" and not a listview. I would like to be able to work with real control object's...
1
1502
by: Sam Martin | last post by:
hi all, I'm really jarred off with the ListView that comes with the .NET v1.1. Why didn't they bother to provide a nicely wrapped implentation of the Win32 ListView control? with support for retieving column orders, setting images for sub items, access to the column headers, etc, the list goes on. I've implemented numerous different classes derived from the .NET ListView, mainly doing sutff like providing methods which return column...
3
2612
by: Holmes | last post by:
Hello Ran into a bit of a problem here and have now exhausted my resources to getting this working What I am trying to do is load and show a simple vb form with a listbox in it Dim frm_nc_code As New frm_nc_sen frm_nc_code.Show( Well what I want to have happen is it loads the form then shows all of the controls on the form (especially the listview control which should be blank at this time)
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
6
5037
by: Jack | last post by:
Hello, I've noticed through searching this group's previous posts that one can get the item the mouse is over in a listview control but I did not see how to get the subitem the mouse is over. Is this possible? I intend on replacing an ActiveX grid with a listview control from a VB6 application that I've upgraded to VB .NET. The existing functionlality uses the mouseover event of the grid to display specific information within...
1
7715
by: The Confessor | last post by:
I currently have a listbox in my program which I populate with data from a random access file as follows: For T = 1 To HighestPointID FileGet(1, Point(T), T) ListBox_Point.Items.Add(T & " Lat: " & Point(T).Latitude...) Next I end up with data in the following format in each ListBox line. 1 Lat: 42.5003, Long: -70.9249, Ele 161
12
3412
by: garyusenet | last post by:
I have had no replies to my previous post so perhaps I didn't write it good enough. Please excuse new thread but i wanted to break from the last thread hopefully this thread will be better. Very simple. I would like to create listviewitem's for display in a listview control. The listview items need to contain properties from Internet Explorer windows i've managed to collect into an arraylist.
10
4049
by: Rob | last post by:
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 ?
1
2671
by: a | last post by:
Hi I would like to add some additional custom features to the listview, like cell editing. The created object will be added to the form as part of the GUI, and it should be able to handle events. I will create a class which conains the listview. Should I inherit this class from any existing class? If yes, which class should I inherit from? Or, should I just inherit my class from listview and add my add my additional features?
0
8823
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9530
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
9363
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
9312
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
9238
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
6073
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4593
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3300
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
3
2206
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.