ListView problem in VB .NET 
Author Message
 ListView problem in VB .NET

I believe I've found a ListView bug in Microsoft Visual Basic .NET
Version 7.0.9466.  If this is a bug what is the process for
submitting it to Microsoft, how do I track it, and how will I know
if / when it gets fixed?  Thanks.

The problem involves the detail view and initialization of the
list view's large image list.  If you initialize the large image
list before adding ListViewItem objects it will never show any
contents in the detail view.

Place the following test case in Form1_Load of a Windows app
that has a ListView control named ListView1:

****************************************************************

' These ImageList objects would contain images in real code.
' ImageList contents do not affect this problem.  Static
' ImageList objects have the same behavior.
'
Dim imageListSmall As New ImageList()
Dim imageListLarge As New ImageList()

' Associating the LargeImageList before adding ListViewItem objects
' causes the ListView to be empty when using the Detail view.  List
' and Icon views work just fine.
'
'ListView1.LargeImageList = imageListLarge
ListView1.SmallImageList = imageListSmall
ListView1.Columns.Add("Item Column", -2, HorizontalAlignment.Left)
ListView1.Columns.Add("Column 2", -2, HorizontalAlignment.Left)
ListView1.Columns.Add("Column 3", -2, HorizontalAlignment.Left)

' First Load
ListView1.BeginUpdate()
ListView1.View = View.Details
Dim item1 As New ListViewItem("item1")
item1.SubItems.Add("1")
item1.SubItems.Add("2")
ListView1.Items.Add(item1)
Dim item2 As New ListViewItem("item2")
item2.SubItems.Add("3")
item2.SubItems.Add("4")
ListView1.Items.Add(item2)
ListView1.LargeImageList = imageListLarge ' Must be called once.
ListView1.EndUpdate()

ListView1.View = View.SmallIcon ' User selected other views ...
ListView1.View = View.List
ListView1.Items.Clear() ' User action requires new ListView contents ...

' Second Load
ListView1.BeginUpdate()
ListView1.View = View.Details
Dim item3 As New ListViewItem("item3")
item3.SubItems.Add("a")
item3.SubItems.Add("b")
ListView1.Items.Add(item3)
Dim item4 As New ListViewItem("item4")
item4.SubItems.Add("c")
item4.SubItems.Add("d")
ListView1.Items.Add(item4)
ListView1.EndUpdate()
--
                     Brian Wolfe, Senior Software Engineer / Architect
    o    __________  Austin Provider Solutions, http://www.*-*-*.com/

  _\__`[__________|
   ] [ \, ][    ][



Sat, 18 Sep 2004 03:24:29 GMT  
 ListView problem in VB .NET
Hi Erian,

I am nt able to reproduce the problem on my site. Currently I am working
with VS .Net sp1.  Is this same with yours?

Luke

(This posting is provided "AS IS", with no warranties, and confers no
rights.)



Sat, 18 Sep 2004 15:21:41 GMT  
 ListView problem in VB .NET
Hi Brian,

In fact, I have tried to uncommited the line "ListView1.LargeImageList =
imageListLarge". Finally, I have found the difference between us. In my
program, I set the column with a fixed size:

ListView1.Columns.Add("Column1", 60, HorizontalAlignment.Left)
ListView1.Columns.Add("Column2", 60, HorizontalAlignment.Left)
ListView1.Columns.Add("Column3", 60, HorizontalAlignment.Left)

In this way, the problem woulnd't occur.

You can add a line at the end of Form_Load() to see the difference :

MsgBox(ListView1.Columns(0).Width)

It seems that it can't calculate the column's width without
"LargeImageList" or have it before column was added.  

Luke

(This posting is provided "AS IS", with no warranties, and confers no
rights.)



Mon, 20 Sep 2004 16:03:04 GMT  
 ListView problem in VB .NET
I have noticed many (sometimes non-deterministic) problems with the ListView
control in .NET (using from VB.NET Professional, release edition w/ .net
Framework sp1).  Mostly, the issues I've seen seem to have to do with
imageLists, StateImageLists in LargeIcon display mode:  image indexes
disappearing, layouts changing from execution to execution, images
disappearing, state images randomly appearing and disappearing.

Here is a deterministic bug.  No code needed.

1.  Create two image lists (ilLarge, ilStates) containing a couple of images
each.  Use different images in each list.
2.  Create ListView1 and assign ilLarge as the LargeImageList, ilStates as
the StateImageList.
3.  Add an item to the ListView1.Items collection from the designer.  Choose
an ImageIndex for the item (fine).  Attempt to choose a StateImageIndex
(BUG: you will be presented with the LargeImageList, not the
StateImageList).  Continue anyway, choosing StateItemIndex = 0.  The
designer will correctly apply the 1st stateImage from ilStates.
4. You may save and reload this form now, and the state image appears fine.
now run the project.  BUG:  Viola, the state image is gone.
(Nondeterministic BUG):  Sometimes it will be gone from the designer as
well - stateimageindex is back to (none), althought that didn't happen in
this simple case.  It seems to have to do with in what container the list is
contained.
5.  Even if you attempt to reset the stateImageList and StateImageindex from
code, it will (usually) fail.
6.  While trying the simple case for replication, I saw an interested
run-time error message I hadn't seen before:
 sender.StateImageList Run-time exception thrown :
System.MissingMemberException - Public member 'StateImageList' on type
'frmMain' not found.  Perhaps the ListViewItems class is referencing one
container too far to find its StateImageList.

Eric Anderson


Quote:
> I believe I've found a ListView bug in Microsoft Visual Basic .NET
> Version 7.0.9466.  If this is a bug what is the process for
> submitting it to Microsoft, how do I track it, and how will I know
> if / when it gets fixed?  Thanks.

> The problem involves the detail view and initialization of the
> list view's large image list.  If you initialize the large image
> list before adding ListViewItem objects it will never show any
> contents in the detail view.

> Place the following test case in Form1_Load of a Windows app
> that has a ListView control named ListView1:

> ****************************************************************

> ' These ImageList objects would contain images in real code.
> ' ImageList contents do not affect this problem.  Static
> ' ImageList objects have the same behavior.
> '
> Dim imageListSmall As New ImageList()
> Dim imageListLarge As New ImageList()

> ' Associating the LargeImageList before adding ListViewItem objects
> ' causes the ListView to be empty when using the Detail view.  List
> ' and Icon views work just fine.
> '
> 'ListView1.LargeImageList = imageListLarge
> ListView1.SmallImageList = imageListSmall
> ListView1.Columns.Add("Item Column", -2, HorizontalAlignment.Left)
> ListView1.Columns.Add("Column 2", -2, HorizontalAlignment.Left)
> ListView1.Columns.Add("Column 3", -2, HorizontalAlignment.Left)

> ' First Load
> ListView1.BeginUpdate()
> ListView1.View = View.Details
> Dim item1 As New ListViewItem("item1")
> item1.SubItems.Add("1")
> item1.SubItems.Add("2")
> ListView1.Items.Add(item1)
> Dim item2 As New ListViewItem("item2")
> item2.SubItems.Add("3")
> item2.SubItems.Add("4")
> ListView1.Items.Add(item2)
> ListView1.LargeImageList = imageListLarge ' Must be called once.
> ListView1.EndUpdate()

> ListView1.View = View.SmallIcon ' User selected other views ...
> ListView1.View = View.List
> ListView1.Items.Clear() ' User action requires new ListView contents ...

> ' Second Load
> ListView1.BeginUpdate()
> ListView1.View = View.Details
> Dim item3 As New ListViewItem("item3")
> item3.SubItems.Add("a")
> item3.SubItems.Add("b")
> ListView1.Items.Add(item3)
> Dim item4 As New ListViewItem("item4")
> item4.SubItems.Add("c")
> item4.SubItems.Add("d")
> ListView1.Items.Add(item4)
> ListView1.EndUpdate()
> --
>                      Brian Wolfe, Senior Software Engineer / Architect
>     o    __________  Austin Provider Solutions, http://austinps.com

>   _\__`[__________|
>    ] [ \, ][    ][



Tue, 21 Sep 2004 08:53:22 GMT  
 ListView problem in VB .NET
Please ignore (6.) below.  That exception was generated by the debug watch
window.


Quote:
> I have noticed many (sometimes non-deterministic) problems with the
ListView
> control in .NET (using from VB.NET Professional, release edition w/ .net
> Framework sp1).  Mostly, the issues I've seen seem to have to do with
> imageLists, StateImageLists in LargeIcon display mode:  image indexes
> disappearing, layouts changing from execution to execution, images
> disappearing, state images randomly appearing and disappearing.

> Here is a deterministic bug.  No code needed.

> 1.  Create two image lists (ilLarge, ilStates) containing a couple of
images
> each.  Use different images in each list.
> 2.  Create ListView1 and assign ilLarge as the LargeImageList, ilStates as
> the StateImageList.
> 3.  Add an item to the ListView1.Items collection from the designer.
Choose
> an ImageIndex for the item (fine).  Attempt to choose a StateImageIndex
> (BUG: you will be presented with the LargeImageList, not the
> StateImageList).  Continue anyway, choosing StateItemIndex = 0.  The
> designer will correctly apply the 1st stateImage from ilStates.
> 4. You may save and reload this form now, and the state image appears
fine.
> now run the project.  BUG:  Viola, the state image is gone.
> (Nondeterministic BUG):  Sometimes it will be gone from the designer as
> well - stateimageindex is back to (none), althought that didn't happen in
> this simple case.  It seems to have to do with in what container the list
is
> contained.
> 5.  Even if you attempt to reset the stateImageList and StateImageindex
from
> code, it will (usually) fail.
> 6.  While trying the simple case for replication, I saw an interested
> run-time error message I hadn't seen before:
>  sender.StateImageList Run-time exception thrown :
> System.MissingMemberException - Public member 'StateImageList' on type
> 'frmMain' not found.  Perhaps the ListViewItems class is referencing one
> container too far to find its StateImageList.

> Eric Anderson



> > I believe I've found a ListView bug in Microsoft Visual Basic .NET
> > Version 7.0.9466.  If this is a bug what is the process for
> > submitting it to Microsoft, how do I track it, and how will I know
> > if / when it gets fixed?  Thanks.

> > The problem involves the detail view and initialization of the
> > list view's large image list.  If you initialize the large image
> > list before adding ListViewItem objects it will never show any
> > contents in the detail view.

> > Place the following test case in Form1_Load of a Windows app
> > that has a ListView control named ListView1:

> > ****************************************************************

> > ' These ImageList objects would contain images in real code.
> > ' ImageList contents do not affect this problem.  Static
> > ' ImageList objects have the same behavior.
> > '
> > Dim imageListSmall As New ImageList()
> > Dim imageListLarge As New ImageList()

> > ' Associating the LargeImageList before adding ListViewItem objects
> > ' causes the ListView to be empty when using the Detail view.  List
> > ' and Icon views work just fine.
> > '
> > 'ListView1.LargeImageList = imageListLarge
> > ListView1.SmallImageList = imageListSmall
> > ListView1.Columns.Add("Item Column", -2, HorizontalAlignment.Left)
> > ListView1.Columns.Add("Column 2", -2, HorizontalAlignment.Left)
> > ListView1.Columns.Add("Column 3", -2, HorizontalAlignment.Left)

> > ' First Load
> > ListView1.BeginUpdate()
> > ListView1.View = View.Details
> > Dim item1 As New ListViewItem("item1")
> > item1.SubItems.Add("1")
> > item1.SubItems.Add("2")
> > ListView1.Items.Add(item1)
> > Dim item2 As New ListViewItem("item2")
> > item2.SubItems.Add("3")
> > item2.SubItems.Add("4")
> > ListView1.Items.Add(item2)
> > ListView1.LargeImageList = imageListLarge ' Must be called once.
> > ListView1.EndUpdate()

> > ListView1.View = View.SmallIcon ' User selected other views ...
> > ListView1.View = View.List
> > ListView1.Items.Clear() ' User action requires new ListView contents ...

> > ' Second Load
> > ListView1.BeginUpdate()
> > ListView1.View = View.Details
> > Dim item3 As New ListViewItem("item3")
> > item3.SubItems.Add("a")
> > item3.SubItems.Add("b")
> > ListView1.Items.Add(item3)
> > Dim item4 As New ListViewItem("item4")
> > item4.SubItems.Add("c")
> > item4.SubItems.Add("d")
> > ListView1.Items.Add(item4)
> > ListView1.EndUpdate()
> > --
> >                      Brian Wolfe, Senior Software Engineer / Architect
> >     o    __________  Austin Provider Solutions, http://austinps.com

> >   _\__`[__________|
> >    ] [ \, ][    ][



Tue, 21 Sep 2004 19:11:02 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. ListView problem in VB .NET

2. Problems With Cookies In ASP.NET/VB.NET

3. Problem with VB.NET under .NET 2003 Final beta

4. Date problems with XML in ASP.NET / VB.NET- newbie question

5. INSERT into access database using vb.net/ado.net..problem

6. SelectedIndex of an ListView under vb.net

7. VB.NET: ListView Sorting

8. scroll to listview row in vb.net

9. listview in vb.net with contains from IList to find parital matches

10. vb.net listview - how to tell if it is selected

11. ListView in VB.NET

12. VB.net listview strange behavior on key press

 

 
Powered by phpBB® Forum Software