473,324 Members | 2,257 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,324 software developers and data experts.

listview and hiding 1 columns

Hi,

I have a listview in report mode.
I have 3 columns in this listview and 1 column i would like to hide it from user's view.

i tried to give width = 0 but user is still able to resize column after in runtime mode.
So, could someone help me please ?
thx,
Maileen
Nov 21 '05 #1
6 3006
First you need to cancel the column-resize event as it is called (the first
sub below does this).
Next you need to reset the size back to 0 when the mouse is released (the
second sub does this).

You need both of these subs to make it work properly. Try it with just one
or the other to see what happens otherwise...
Private Sub ListView1_ColResizing(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.ColumnWidthChangingEventArgs) _
Handles ListView1.ColumnWidthChanging

' called when the column is being dragged

' set the column index to whichever one you want to cancel:
If e.ColumnIndex = 1 Then
e.Cancel = True ' cancels the resize event, (stops the resize
from being displayed on the screen)
End If

End Sub
Private Sub ListView1_ColResized(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.ColumnWidthChangedEventArgs) _
Handles ListView1.ColumnWidthChanged

' called when the mouse button is released

' set the column index to whichever one you want to cancel:
If e.Column = 1 Then
ListView2.Columns(1).Width = 0 ' reset size back to 0
End If
End Sub


"Maileen" <no*****@nospam.com> wrote in message
news:OT**************@TK2MSFTNGP09.phx.gbl...
Hi,

I have a listview in report mode.
I have 3 columns in this listview and 1 column i would like to hide it
from user's view.

i tried to give width = 0 but user is still able to resize column after in
runtime mode.
So, could someone help me please ?
thx,
Maileen

Nov 21 '05 #2
oops sorry...
the 3rd-to-last line should read:

ListView1.Columns(1).Width = 0 ' reset size back to 0

instead of:
ListView2.Columns(1).Width = 0 ' reset size back to 0


"Wicksy" <wi*****@nospam-yahoo.com> wrote in message
news:dh*********@news.freedom2surf.net...
First you need to cancel the column-resize event as it is called (the
first sub below does this).
Next you need to reset the size back to 0 when the mouse is released (the
second sub does this).

You need both of these subs to make it work properly. Try it with just one
or the other to see what happens otherwise...
Private Sub ListView1_ColResizing(ByVal sender As System.Object, ByVal e
As System.Windows.Forms.ColumnWidthChangingEventArgs) _
Handles ListView1.ColumnWidthChanging

' called when the column is being dragged

' set the column index to whichever one you want to cancel:
If e.ColumnIndex = 1 Then
e.Cancel = True ' cancels the resize event, (stops the resize
from being displayed on the screen)
End If

End Sub
Private Sub ListView1_ColResized(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.ColumnWidthChangedEventArgs) _
Handles ListView1.ColumnWidthChanged

' called when the mouse button is released

' set the column index to whichever one you want to cancel:
If e.Column = 1 Then
ListView2.Columns(1).Width = 0 ' reset size back to 0
End If
End Sub


"Maileen" <no*****@nospam.com> wrote in message
news:OT**************@TK2MSFTNGP09.phx.gbl...
Hi,

I have a listview in report mode.
I have 3 columns in this listview and 1 column i would like to hide it
from user's view.

i tried to give width = 0 but user is still able to resize column after
in runtime mode.
So, could someone help me please ?
thx,
Maileen


Nov 21 '05 #3
Sorry but there are things that i don't understand...
when i'm checking in help, there is nothing about :

ListView1.ColumnWidthChanging
System.Windows.Forms.ColumnWidthChangingEventArgs
ListView1.ColumnWidthChanging
System.Windows.Forms.ColumnWidthChangedEventArgs

so how can i do that ?

thanks a lot,
Maileen

Wicksy wrote:
oops sorry...
the 3rd-to-last line should read:

ListView1.Columns(1).Width = 0 ' reset size back to 0

instead of:
ListView2.Columns(1).Width = 0 ' reset size back to 0


"Wicksy" <wi*****@nospam-yahoo.com> wrote in message
news:dh*********@news.freedom2surf.net...
First you need to cancel the column-resize event as it is called (the
first sub below does this).
Next you need to reset the size back to 0 when the mouse is released (the
second sub does this).

You need both of these subs to make it work properly. Try it with just one
or the other to see what happens otherwise...
Private Sub ListView1_ColResizing(ByVal sender As System.Object, ByVal e
As System.Windows.Forms.ColumnWidthChangingEventArgs) _
Handles ListView1.ColumnWidthChanging

' called when the column is being dragged

' set the column index to whichever one you want to cancel:
If e.ColumnIndex = 1 Then
e.Cancel = True ' cancels the resize event, (stops the resize
from being displayed on the screen)
End If

End Sub
Private Sub ListView1_ColResized(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.ColumnWidthChangedEventArgs) _
Handles ListView1.ColumnWidthChanged

' called when the mouse button is released

' set the column index to whichever one you want to cancel:
If e.Column = 1 Then
ListView2.Columns(1).Width = 0 ' reset size back to 0
End If
End Sub


"Maileen" <no*****@nospam.com> wrote in message
news:OT**************@TK2MSFTNGP09.phx.gbl...
Hi,

I have a listview in report mode.
I have 3 columns in this listview and 1 column i would like to hide it
from user's view.

i tried to give width = 0 but user is still able to resize column after
in runtime mode.
So, could someone help me please ?
thx,
Maileen


Nov 21 '05 #4
how can you do what? you just paste in the code.

ListView1.ColumnWidthChanging is the event (ie. a Column Width has changed
in ListView1)

System.Windows.Forms.ColumnWidthChangedEventArgs is an object containing the
event arguments (eg. which column was it?) that is thrown when AFTER a
column width has changed.
"Maileen" <no*****@nospam.com> wrote in message
news:Ob****************@TK2MSFTNGP15.phx.gbl...
Sorry but there are things that i don't understand...
when i'm checking in help, there is nothing about :

ListView1.ColumnWidthChanging
System.Windows.Forms.ColumnWidthChangingEventArgs
ListView1.ColumnWidthChanging
System.Windows.Forms.ColumnWidthChangedEventArgs

so how can i do that ?

thanks a lot,
Maileen

Wicksy wrote:
oops sorry...
the 3rd-to-last line should read:

ListView1.Columns(1).Width = 0 ' reset size back to 0

instead of:
ListView2.Columns(1).Width = 0 ' reset size back to 0


"Wicksy" <wi*****@nospam-yahoo.com> wrote in message
news:dh*********@news.freedom2surf.net...
First you need to cancel the column-resize event as it is called (the
first sub below does this).
Next you need to reset the size back to 0 when the mouse is released
(the second sub does this).

You need both of these subs to make it work properly. Try it with just
one or the other to see what happens otherwise...
Private Sub ListView1_ColResizing(ByVal sender As System.Object, ByVal e
As System.Windows.Forms.ColumnWidthChangingEventArgs) _
Handles ListView1.ColumnWidthChanging

' called when the column is being dragged

' set the column index to whichever one you want to cancel:
If e.ColumnIndex = 1 Then
e.Cancel = True ' cancels the resize event, (stops the resize
from being displayed on the screen)
End If

End Sub
Private Sub ListView1_ColResized(ByVal sender As System.Object, ByVal e
As System.Windows.Forms.ColumnWidthChangedEventArgs) _
Handles ListView1.ColumnWidthChanged

' called when the mouse button is released

' set the column index to whichever one you want to cancel:
If e.Column = 1 Then
ListView2.Columns(1).Width = 0 ' reset size back to 0
End If
End Sub


"Maileen" <no*****@nospam.com> wrote in message
news:OT**************@TK2MSFTNGP09.phx.gbl...
Hi,

I have a listview in report mode.
I have 3 columns in this listview and 1 column i would like to hide it
from user's view.

i tried to give width = 0 but user is still able to resize column after
in runtime mode.
So, could someone help me please ?
thx,
Maileen


Nov 21 '05 #5
in my .net 2003, Listview does not have such event :(
i don't see it when i'm searching for it and even if with autocorrection of syntax.

after controlling my doc, i do not have System.Windows.Forms.ColumnWidthChangedEventArgs.. .
which version of .net do you use ?
Wicksy wrote:
how can you do what? you just paste in the code.

ListView1.ColumnWidthChanging is the event (ie. a Column Width has changed
in ListView1)

System.Windows.Forms.ColumnWidthChangedEventArgs is an object containing the
event arguments (eg. which column was it?) that is thrown when AFTER a
column width has changed.
"Maileen" <no*****@nospam.com> wrote in message
news:Ob****************@TK2MSFTNGP15.phx.gbl...
Sorry but there are things that i don't understand...
when i'm checking in help, there is nothing about :

ListView1.ColumnWidthChanging
System.Windows.Forms.ColumnWidthChangingEventArgs
ListView1.ColumnWidthChanging
System.Windows.Forms.ColumnWidthChangedEventArgs

so how can i do that ?

thanks a lot,
Maileen

Wicksy wrote:
oops sorry...
the 3rd-to-last line should read:

ListView1.Columns(1).Width = 0 ' reset size back to 0

instead of:
ListView2.Columns(1).Width = 0 ' reset size back to 0


"Wicksy" <wi*****@nospam-yahoo.com> wrote in message
news:dh*********@news.freedom2surf.net...
First you need to cancel the column-resize event as it is called (the
first sub below does this).
Next you need to reset the size back to 0 when the mouse is released
(the second sub does this).

You need both of these subs to make it work properly. Try it with just
one or the other to see what happens otherwise...
Private Sub ListView1_ColResizing(ByVal sender As System.Object, ByVal e
As System.Windows.Forms.ColumnWidthChangingEventArgs) _
Handles ListView1.ColumnWidthChanging

' called when the column is being dragged

' set the column index to whichever one you want to cancel:
If e.ColumnIndex = 1 Then
e.Cancel = True ' cancels the resize event, (stops the resize
from being displayed on the screen)
End If

End Sub
Private Sub ListView1_ColResized(ByVal sender As System.Object, ByVal e
As System.Windows.Forms.ColumnWidthChangedEventArgs) _
Handles ListView1.ColumnWidthChanged

' called when the mouse button is released

' set the column index to whichever one you want to cancel:
If e.Column = 1 Then
ListView2.Columns(1).Width = 0 ' reset size back to 0
End If
End Sub


"Maileen" <no*****@nospam.com> wrote in message
news:OT**************@TK2MSFTNGP09.phx.gbl...
> Hi,
>
> I have a listview in report mode.
> I have 3 columns in this listview and 1 column i would like to hide it
> from user's view.
>
> i tried to give width = 0 but user is still able to resize column after
> in runtime mode.
> So, could someone help me please ?
> thx,
> Maileen

Nov 21 '05 #6
hmmm... im using 2005 (.NET 2.0.5)

in that case, sorry I don't know the answer.

Apart from "upgrade to 2005" ;)
"Maileen" <no*****@nospam.com> wrote in message
news:Of**************@tk2msftngp13.phx.gbl...
in my .net 2003, Listview does not have such event :(
i don't see it when i'm searching for it and even if with autocorrection
of syntax.

after controlling my doc, i do not have
System.Windows.Forms.ColumnWidthChangedEventArgs.. .
which version of .net do you use ?
Wicksy wrote:
how can you do what? you just paste in the code.

ListView1.ColumnWidthChanging is the event (ie. a Column Width has
changed in ListView1)

System.Windows.Forms.ColumnWidthChangedEventArgs is an object containing
the event arguments (eg. which column was it?) that is thrown when AFTER
a column width has changed.
"Maileen" <no*****@nospam.com> wrote in message
news:Ob****************@TK2MSFTNGP15.phx.gbl...
Sorry but there are things that i don't understand...
when i'm checking in help, there is nothing about :

ListView1.ColumnWidthChanging
System.Windows.Forms.ColumnWidthChangingEventArgs
ListView1.ColumnWidthChanging
System.Windows.Forms.ColumnWidthChangedEventArgs

so how can i do that ?

thanks a lot,
Maileen

Wicksy wrote:
oops sorry...
the 3rd-to-last line should read:

ListView1.Columns(1).Width = 0 ' reset size back to 0

instead of:
ListView2.Columns(1).Width = 0 ' reset size back to 0


"Wicksy" <wi*****@nospam-yahoo.com> wrote in message
news:dh*********@news.freedom2surf.net...
> First you need to cancel the column-resize event as it is called (the
> first sub below does this).
> Next you need to reset the size back to 0 when the mouse is released
> (the second sub does this).
>
> You need both of these subs to make it work properly. Try it with just
> one or the other to see what happens otherwise...
>
>
> Private Sub ListView1_ColResizing(ByVal sender As System.Object, ByVal
> e As System.Windows.Forms.ColumnWidthChangingEventArgs) _
> Handles ListView1.ColumnWidthChanging
>
> ' called when the column is being dragged
>
> ' set the column index to whichever one you want to cancel:
> If e.ColumnIndex = 1 Then
> e.Cancel = True ' cancels the resize event, (stops the
> resize from being displayed on the screen)
> End If
>
> End Sub
>
>
> Private Sub ListView1_ColResized(ByVal sender As System.Object, ByVal
> e As System.Windows.Forms.ColumnWidthChangedEventArgs) _
> Handles ListView1.ColumnWidthChanged
>
> ' called when the mouse button is released
>
> ' set the column index to whichever one you want to cancel:
> If e.Column = 1 Then
> ListView2.Columns(1).Width = 0 ' reset size back to 0
> End If
> End Sub
>
>
>
>
> "Maileen" <no*****@nospam.com> wrote in message
> news:OT**************@TK2MSFTNGP09.phx.gbl...
>> Hi,
>>
>> I have a listview in report mode.
>> I have 3 columns in this listview and 1 column i would like to hide
>> it from user's view.
>>
>> i tried to give width = 0 but user is still able to resize column
>> after in runtime mode.
>> So, could someone help me please ?
>> thx,
>> Maileen

Nov 21 '05 #7

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

Similar topics

6
by: VM | last post by:
How can I fill up a listview with text file contents? My listview has two columns and the first column fills up with a while loop: while (myString != null) { myString = sr.Readline();...
2
by: Nic | last post by:
Hi, The original creators of the ListView control never envisioned that we'd want to override the Columns property with our own version, so they didn't mark it as Overridable. This means we...
1
by: rallard | last post by:
After the following subroutine executes, my listview shows a scroll bar on the right, but it is otherwise blank. I've checked for things like locked=false, visable=true, font color same as...
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...
5
by: John Devlon | last post by:
Hi, Does anyone know how to get a value of a second column of a selected item in Listview. I've create a listview and added this code Listview.Items.Clear() Listview.Columns.Clear()...
1
by: samoore33 | last post by:
I found this code on MSDN, and it works great. It creates a ListView dynamically and add items to it and all. It is great. I have changed a few of the column names to suit me. Dim listView1 As...
1
by: MrNobody | last post by:
what's the trick in showing/hiding columns in ListView's Details view mode? I can change a columns width to 0 and it effectively makes it disappear but then you can actually resize the column to...
1
by: =?Utf-8?B?THluYkBtcy5jb20=?= | last post by:
I have a executable winforms application I would like to change. I use quite a number of listview controls in my main form. I dump about 15 columns of data into a couple of listviews. This data...
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
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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...

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.