473,725 Members | 2,278 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

listview columnorder setting /retrieving ??

Hi

I have set the columreorder to true

Is there a way to get/set the current columnorder, so i can restore the
order from a saved setting ?
Johan
Nov 15 '05 #1
2 2293
Hi Johan,

The following should work similar to your needs. By storing arrays of
ColumnHeaders, you're actually getting references to the same ColumnHeader
objects that are currently in your ListView. Thus beware, if something in
the ColumnHeader object changes (say, the Text), then it'll change for all
the arrays that you capture. The only specific part of getting and
settings these arrays are that they capture the ordering of the particular
columns. If you wish to capture the exact state, then you'll need to copy
the ColumnHeader objects too.

Notice, for the SetColumnOrder( ) method, BeginUpdate() and EndUpdate() are
called to ensure that clearing the columns and adding the columns get
updated all at once for the end user, instead of the user being able to
"see" the intermediate zero-column state.

Do you have any further questions?

using System.Windows. Forms;
using ColumnHeaderCol lection =
System.Windows. Forms.ListView. ColumnHeaderCol lection;
...
public ColumnHeader[] GetColumnOrder( ListView lView) {
ColumnHeaderCol lection columns = lView.Columns;
int count = columns.Count;
ColumnHeader[] arr = new ColumnHeader[count];
for(int i = 0; i < count; i++) {
arr[i] = columns[i];
}
return arr;
}

public void SetColumnOrder( ListView lView, ColumnHeader[] arr) {
ColumnHeaderCol lection columns = lView.Columns;
lView.BeginUpda te();
columns.Clear() ;
columns.AddRang e(arr);
lView.EndUpdate ();
}
...

Hope this helps,

Theo Yaung
Software Design Engineer
Visual Studio .NET Updates / Sustained Engineering
Microsoft Corp.

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
Reply-To: "Sagaert Johan" <sa*******@hotm ail.com>
From: "Sagaert Johan" <sa*******@hotm ail.com>
Subject: listview columnorder setting /retrieving ??
Date: Sun, 26 Oct 2003 11:02:33 +0100

Hi

I have set the columreorder to true

Is there a way to get/set the current columnorder, so i can restore the
order from a saved setting ?
Johan

--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

Note: For the benefit of the community-at-large, all responses to this
message are best directed to the newsgroup/thread from which they
originated.

Nov 15 '05 #2
Thanks that will do the job !

"Theo Yaung [Microsoft]" <th************ *********@onlin e.microsoft.com >
wrote in message news:Kt******** ******@cpmsftng xa06.phx.gbl...
Hi Johan,

The following should work similar to your needs. By storing arrays of
ColumnHeaders, you're actually getting references to the same ColumnHeader
objects that are currently in your ListView. Thus beware, if something in
the ColumnHeader object changes (say, the Text), then it'll change for all
the arrays that you capture. The only specific part of getting and
settings these arrays are that they capture the ordering of the particular
columns. If you wish to capture the exact state, then you'll need to copy
the ColumnHeader objects too.

Notice, for the SetColumnOrder( ) method, BeginUpdate() and EndUpdate() are
called to ensure that clearing the columns and adding the columns get
updated all at once for the end user, instead of the user being able to
"see" the intermediate zero-column state.

Do you have any further questions?

using System.Windows. Forms;
using ColumnHeaderCol lection =
System.Windows. Forms.ListView. ColumnHeaderCol lection;
...
public ColumnHeader[] GetColumnOrder( ListView lView) {
ColumnHeaderCol lection columns = lView.Columns;
int count = columns.Count;
ColumnHeader[] arr = new ColumnHeader[count];
for(int i = 0; i < count; i++) {
arr[i] = columns[i];
}
return arr;
}

public void SetColumnOrder( ListView lView, ColumnHeader[] arr) {
ColumnHeaderCol lection columns = lView.Columns;
lView.BeginUpda te();
columns.Clear() ;
columns.AddRang e(arr);
lView.EndUpdate ();
}
...

Hope this helps,

Theo Yaung
Software Design Engineer
Visual Studio .NET Updates / Sustained Engineering
Microsoft Corp.

This posting is provided "AS IS" with no warranties, and confers no rights. --------------------
Reply-To: "Sagaert Johan" <sa*******@hotm ail.com>
From: "Sagaert Johan" <sa*******@hotm ail.com>
Subject: listview columnorder setting /retrieving ??
Date: Sun, 26 Oct 2003 11:02:33 +0100

Hi

I have set the columreorder to true

Is there a way to get/set the current columnorder, so i can restore the
order from a saved setting ?
Johan
--
This posting is provided "AS IS" with no warranties, and confers no

rights. Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

Note: For the benefit of the community-at-large, all responses to this
message are best directed to the newsgroup/thread from which they
originated.

Nov 15 '05 #3

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

Similar topics

1
23703
by: andrewcw | last post by:
The clcik event on the ListView control seems to trigger off the item level ( the first column ). I would like to be able to trap the click event on a particular subitem ( a specific column's row ). If possible, what do I do to activate that 'cell' - thanks. I thought that listView.LabelEdit = true; would enable me to navigate into the cells or something like listView.items .subitems.LabelEdit - but I did not see such a property....
2
11658
by: Michael C | last post by:
Hi all, When I try to use the GetItemAt (e.X, e.Y) method in a ListView MouseDown() event, it only works some of the time. If I right-click on an open area of the ListView, I get null back as expected. If I right-click on a ListViewItem, I get that ListViewItem back. But then... if I right-click on an open area of the ListView again I get the last ListViewItem I clicked on back... I'm sure there's a way around this. GetItemAt...
0
1371
by: Per Rollvang | last post by:
Hi All! I use a special ListViewItemComparer-class to sort items in a listview for any column, and I have also allowed column-reordering. So far so good, but if I click the columnheader of any column, and the columnorder is not 'default', the listview 'forget' my column-re-ordering (i.e 0 2 1), and sets column-order back to default (i.e. 0 1 2). Is there anyone that might know what I have forgot to code in my
0
893
by: John Dann | last post by:
I'm creating a Listview control in details view under VB.Net which always has 31 rows (populated at runtime) and 4 columns (ie 1 item plus 3 subitems) of specified width. But at runtime and provided there is surplus space on the form available (the form is not fixed size), the control is displayed with a 5th (blank) column and as many blank rows below row 31 as form space allows. I'd like to do two things: 1. Stop the blank 5th...
8
1906
by: Mr. B | last post by:
I think I'm missing something here... but is there someway to get the String information from a ListView without the garbage that I get? For example, I've a ListView with a couple of columns... and if I want to get the String in a Column and I use something like LItem.SubItems(2).ToString. This give me something like "ListViewSubItem: {60-004}" ---> where '60-004' is the string I'm looking for. So I have to 'remove the before and after...
4
10693
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
7371
by: David Jackson | last post by:
Hello, I'm using VS.NET 2005. I have a ListView populated with data pulled from a SQL Server database. I have wired up a SelectedIndexChanged event, but I can't find any way of retrieving the value of the previously selected record. For example, if the ListView looks like this:
12
4028
by: Tom Bean | last post by:
I am trying to display a ContextMenuStrip when a user right-clicks on an item in a ListView and have encountered a something that seems strange to me. When the ListView is initially populated, no items are selected. When the first item is selected by clicking either the left or right button, the SelectedIndexChanged event fires but not the MouseUp event. After the first item is selected and another item clicked on, both the...
7
3582
by: Brad Pears | last post by:
I have something strange going on - pretty sure it used to work before - and now it does not... Why does the following code not clear a combo box? Me.cboLocation.Text = String.Empty OR Me.cboLocation.Text = ""
0
8752
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
9257
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
9179
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
9116
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
8099
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
6702
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
4519
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...
2
2637
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2157
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.