473,320 Members | 2,146 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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 2261
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 ColumnHeaderCollection =
System.Windows.Forms.ListView.ColumnHeaderCollecti on;
...
public ColumnHeader[] GetColumnOrder(ListView lView) {
ColumnHeaderCollection 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) {
ColumnHeaderCollection columns = lView.Columns;
lView.BeginUpdate();
columns.Clear();
columns.AddRange(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*******@hotmail.com>
From: "Sagaert Johan" <sa*******@hotmail.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*********************@online.microsoft.com>
wrote in message news:Kt**************@cpmsftngxa06.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 ColumnHeaderCollection =
System.Windows.Forms.ListView.ColumnHeaderCollecti on;
...
public ColumnHeader[] GetColumnOrder(ListView lView) {
ColumnHeaderCollection 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) {
ColumnHeaderCollection columns = lView.Columns;
lView.BeginUpdate();
columns.Clear();
columns.AddRange(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*******@hotmail.com>
From: "Sagaert Johan" <sa*******@hotmail.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
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...
2
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...
0
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...
0
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...
8
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......
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: 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...
12
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,...
7
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 ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.