ListView: Strange Behavior...not really a bug though. 
Author Message
 ListView: Strange Behavior...not really a bug though.

This is a multi-part message in MIME format.

------=_NextPart_000_01BC7C82.897D3C50
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

Hi VB programmers, I found something quite weird in the way ListView
control works. If you add a column at index n, you must later refer to it
as column n-1. That's it.

    Const nColPg As Integer = 0
    Const nColPgTy As Integer = 1
    Const nColEO As Integer = 2

    '1 is added to the row number because it seems like
    'you add starting at 1 but you use starting at 0 ???
    lvResults.View = lvwReport
    lvResults.ColumnHeaders.Add nColPg + 1, , "Pg", 100
    lvResults.ColumnHeaders.Add nColPgTy + 1, , "Type", 700
    lvResults.ColumnHeaders.Add nColEO + 1, , "EO", 700

    'Here we use constant without the + 1
    Set itemTemp = lvResults.ListItems.Add
    itemTemp.Text = rs!PageID
    itemTemp.SubItems(nColEO) = rs!EoId
    itemTemp.SubItems(nColPgTy) = rs!EoPageTypeName
    itemTemp.SubItems(nColRev) = rs!RevID

Don't you think it's wierd ?
--

CAE Electronics Ltd
St-Laurent, Quebec, Canada
------=_NextPart_000_01BC7C82.897D3C50
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<html><head></head><BODY bgcolor=3D"#FFFFFF"><p><font size=3D2 =
color=3D"#000000" face=3D"Arial">Hi VB programmers, I found something =
quite weird in the way ListView control works. If you add a column at =
index n, you must later refer to it as column n-1. That's it.<br><font =
face=3D"Courier New"><br> &nbsp;&nbsp;&nbsp;Const nColPg As Integer =3D =
0<br> &nbsp;&nbsp;&nbsp;Const nColPgTy As Integer =3D 1<br> =
&nbsp;&nbsp;&nbsp;Const nColEO As Integer =3D 2<br><br> =
&nbsp;&nbsp;&nbsp;<br> &nbsp;&nbsp;&nbsp;'1 is added to the row number =
because it seems like<br> &nbsp;&nbsp;&nbsp;'you add starting at 1 but =
you use starting at 0 ???<br> &nbsp;&nbsp;&nbsp;lvResults.View =3D =
lvwReport<br> &nbsp;&nbsp;&nbsp;lvResults.ColumnHeaders.Add nColPg + 1, =
, &quot;Pg&quot;, 100<br> &nbsp;&nbsp;&nbsp;lvResults.ColumnHeaders.Add =
nColPgTy + 1, , &quot;Type&quot;, 700<br> =
&nbsp;&nbsp;&nbsp;lvResults.ColumnHeaders.Add nColEO + 1, , =
&quot;EO&quot;, 700<br><br> &nbsp;&nbsp;&nbsp;'Here we use constant =
without the + 1<br> &nbsp;&nbsp;&nbsp;Set itemTemp =3D =
lvResults.ListItems.Add<br> &nbsp;&nbsp;&nbsp;itemTemp.Text =3D =
rs!PageID<br> &nbsp;&nbsp;&nbsp;itemTemp.SubItems(nColEO) =3D =
rs!EoId<br> &nbsp;&nbsp;&nbsp;itemTemp.SubItems(nColPgTy) =3D =
rs!EoPageTypeName<br> &nbsp;&nbsp;&nbsp;itemTemp.SubItems(nColRev) =3D =
rs!RevID<br><font face=3D"Arial"><br>Don't you think it's wierd ?<br>-- =

color=3D"#000000">)<br>CAE Electronics Ltd<br>St-Laurent, Quebec, =
Canada</p>
</font></font></font></font></font></body></html>
------=_NextPart_000_01BC7C82.897D3C50--



Mon, 06 Dec 1999 03:00:00 GMT  
 ListView: Strange Behavior...not really a bug though.

The columns are " 1 based", not zero based.

Change your constants.

Regards,
Dan Hinrichs



Hi VB programmers, I found something quite weird in the way ListView
control works. If you add a column at index n, you must later refer to it
as column n-1. That's it.

    Const nColPg As Integer = 0
    Const nColPgTy As Integer = 1
    Const nColEO As Integer = 2

    '1 is added to the row number because it seems like
    'you add starting at 1 but you use starting at 0 ???
    lvResults.View = lvwReport
    lvResults.ColumnHeaders.Add nColPg + 1, , "Pg", 100
    lvResults.ColumnHeaders.Add nColPgTy + 1, , "Type", 700
    lvResults.ColumnHeaders.Add nColEO + 1, , "EO", 700

    'Here we use constant without the + 1
    Set itemTemp = lvResults.ListItems.Add
    itemTemp.Text = rs!PageID
    itemTemp.SubItems(nColEO) = rs!EoId
    itemTemp.SubItems(nColPgTy) = rs!EoPageTypeName
    itemTemp.SubItems(nColRev) = rs!RevID

Don't you think it's wierd ?
--

CAE Electronics Ltd
St-Laurent, Quebec, Canada
----------



Tue, 07 Dec 1999 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. ListView: Strange Behavior...not really a bug though.

2. Listview strange behavior (bug?)

3. Strange Access behavior - bug?

4. Strange behavior of recordset FieldChangeComplete Event - a bug?

5. ListView.CheckedItems -- strange behavior

6. VB.net listview strange behavior on key press

7. I really found a strange bug, but REALLY strange... check it out...

8. strange bug in executable but not in IDE

9. Stange String Behavior - Bug or Bugged ?

10. Stepping though code - VB Bug?

11. really weird behavior with NUMLOCK

12. Really odd FlexGrid behavior.

 

 
Powered by phpBB® Forum Software