listview and hiding 1 columns

  • Thread starter Thread starter Maileen
  • Start date Start date
M

Maileen

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
 
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
 
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
 
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
 
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.
 
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 ?
 
hmmm... im using 2005 (.NET 2.0.5)

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

Apart from "upgrade to 2005" ;)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top