Column Header - Strange Behavior

A

Aaron

In one of my listviews I have (via the designer) created two columns
at 60 pixels wide each. I've assigned Text to each column header and
set the listview as Detail, as well as make the columns nonclickable
and have checkboxes.

What I'm seeing when I open the form that the listview is on is the
right edge of the first column all the way to the very left, which
means in order to see the column contents, I have to drag the column
header separator way over to the right. Also, I have no text on my
column header (s) and I cannot see anywhere where the second column
even is...it must be out in la la land. I verified through the
debugger that both text strings that make up an item are indeed
populated with text so it's not as if the second column didn't have
any values.

One last thing, I completely deleted the listview and created a whole
new one from scratch on that same form using different column names
and widths, yet I get the exact same result! There isn't anywhere in
code I'm changing any of these settings whatsoever, I just leave them
as I've designed them. Anyone have any clues...it's really
mind-boggling!
 
D

Daniel Moth

Post a reproducible sample (or check it yourself: the designer generated
code is in InitializeComponent).

Cheers
Daniel
 
A

Aaron

Daniel, not sure what's going on here, but here's my button click
event:

Private Sub btnArrived_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles btnArrived.Click
Dim rsDept As New InTheHand.Data.Adoce.Recordset
Dim floorID As String
Dim previousID As String
Dim floor As String
Dim item As New ListViewItem
Dim lvCount As Integer

lvCount = 0
rsDept.Open("SELECT tblServices.Number, tblServices.ServiceID,
tblFloors.FloorID, tblFloors.Floor FROM tblFloors INNER JOIN
tblServices ON tblFloors.FloorID = tblServices.FloorID WHERE
tblServices.Number = " & G_TICKET & " ORDER BY tblServices.FloorID,
tblFloors.Floor ASC", cn)
If Not rsDept.EOF And Not rsDept.BOF Then
frmDeptFloorRoom.Instance().lstDeptFloorRoom.Clear()
rsDept.MoveFirst()
While Not rsDept.EOF
floorID = rsDept.Fields(2).Value().ToString()
floor = rsDept.Fields("Floor").Value()

If lvCount > 0 Then
If floorID <> previousID Then

frmDeptFloorRoom.Instance().lstDeptFloorRoom.Items.Add(New
ListViewItem(New String() {floor, floorID}))
End If
Else

frmDeptFloorRoom.Instance().lstDeptFloorRoom.Items.Add(New
ListViewItem(New String() {floor, floorID}))
End If

lvCount = lvCount + 1
previousID = floorID
rsDept.MoveNext() 'get new values from next record
End While

'Set the listview to receive focus and highlight the first
row
frmDeptFloorRoom.Instance().lstDeptFloorRoom.Focus()
If
(frmDeptFloorRoom.Instance().lstDeptFloorRoom.Items.Count > 0) Then
Dim floorItem As ListViewItem =
frmDeptFloorRoom.Instance().lstDeptFloorRoom.Items(0)
floorItem.Focused = True
floorItem.Selected = True
End If

frmDeptFloorRoom.Instance().lstDeptFloorRoom.Font = New
Font(FontFamily.GenericSansSerif, 8, FontStyle.Regular)
frmDeptFloorRoom.Instance().Text = "My App"
Me.Text = ""
frmDeptFloorRoom.Instance().Show()

End If
End Sub

Stepping through while in debug mode, floor and floorID always have
values in them. Upon further review, I'm not even sure if there is a
second column, or if no values are ever being put into it. This is
the only code that touches my listview, no alterations are being done
anywhere else. I still cannot explain how:

1) the first column is crammed all the way over to the left

2) why no values are being written to the second column

3) why column headers are missing their text

Anyone else ever have this extremely extremely strange behavior? I'm
not a Microsoft basher but unless someone can find something in my
code, I'll assume this is yet another Microsoft bug, and not a
pleasant one at that.
 

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

Top