473,395 Members | 1,987 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,395 software developers and data experts.

ListView Troubles

VB.net issue here.

I've a strange event that I can't seem to figure out...

On my Form, I've a TabControl (two Tabs)...

On my first tab, I load an Ascii file and dump some info onto my ListView
(which is located on my other Tab).

Now IF I click on the 2nd Tab... the Info IS to be sorted out - as I've set
the properties to SORT = Ascending.

But IF I load my data... and DO NOT change tabs... I've found that the
information on the Listview is NOT sorted. At least, not until I click on the
Tab and display the Listview!!!! (which the info is sorted out).

WTF? I don't understand this?

Regards,

Bruce F
Jul 21 '05 #1
4 1808
Mr. B.

This is a kind of usual question about the tabpage. To answer it with a
general answer, AFAIK, are actions in the controls taken when they are
showed (activated).

I hope this helps,

Cor
Jul 21 '05 #2
With Deft Fingers, "Cor Ligthert" <no************@planet.nl> wrote:
Mr. B.

This is a kind of usual question about the tabpage. To answer it with a
general answer, AFAIK, are actions in the controls taken when they are
showed (activated).


Thanks Cor... That was the first place I looked :(

Here is what I have on the TabControl:

Private Sub TabControl1_Click(ByVal eventSender As System.Object, ByVal
eventArgs As System.EventArgs) Handles TabControl1.Click
' Do Things Based on Active Tab Selected

If TabControl1.TabPages(0).Focus() = True Then
btnAddTabs.Enabled = False
btnModTabs.Enabled = False
btnDelTabs.Enabled = False
lblDwgsDelete.Text = "0"
lblDwgsAdded.Text = "0"
txbDwgRename.Text = ""
lblDwgRename.Text = ""
cmbAddDwgTabs.SelectedIndex = 0
Exit Sub
End If

End Sub

So I don't do anything via the TabControl. And like I said, all I do is to
change tabs (and there I don't click on anything). Very strange. But I'll
have to find the answer as it's driving me nuts.

There will be times where changing tabs is not done so I must figure this one
out. I just can't see why it doesn't sort UNLESS it is visible.

Regards,

Bruce F
Jul 21 '05 #3
Since you did not show the code related to the ListView, I am bit hesitant
to ask, do you have the ListView's ListViewItemSorter property set to a
valid IComparer object after loading ListViewItems, like:

foreach (<you data>)
{
ListViewItem item=new ListViewItem()
...
MyListViewItems.Add(item)
}

//This line of code sorts the ListView
MyListView.ListViewItemSorter=<myIComparer>

If you do not have this line of code, the listView will not be sorted. If it
looks like sorted, it is just because the data happens to be in sorted order

I do not think whether the ListView being sorted or not has anything to do
with clicking on TablControl's tab unless you set ListViewItemSorter in that
event handler, which you did not according to your reply to the other post.

"Mr. B" <Us**@NoWhere.com> wrote in message
news:ge********************************@4ax.com...
VB.net issue here.

I've a strange event that I can't seem to figure out...

On my Form, I've a TabControl (two Tabs)...

On my first tab, I load an Ascii file and dump some info onto my ListView
(which is located on my other Tab).

Now IF I click on the 2nd Tab... the Info IS to be sorted out - as I've set the properties to SORT = Ascending.

But IF I load my data... and DO NOT change tabs... I've found that the
information on the Listview is NOT sorted. At least, not until I click on the Tab and display the Listview!!!! (which the info is sorted out).

WTF? I don't understand this?

Regards,

Bruce F

Jul 21 '05 #4
With Deft Fingers, "Norman Yuan" <No*****@NotReal.not> wrote:
Since you did not show the code related to the ListView, I am bit hesitant
to ask, do you have the ListView's ListViewItemSorter property set to a
valid IComparer object after loading ListViewItems, like:
Well... that's because there IS no code to show (grin). Here is the basics...

1) A TabControl with Two (2) tabs.

2) A Standard ListView with Sorted set in the Properties, etc. This is on the
2nd Tab or Tab(1).

3) I load a TEXT file and dumps some 'unsorted' into into the Listbox (two
columns).

4) Now if I build and Array with the Listview info as is, the dump the Array
info into an unsorted Listbox (for Testing purposes), the info is NOT sorted.

However, IF I do #1 to #2 and 'then' do nothing more that switch from Tab(0)
to Tab(1) and back to Tab(0)... and then do #3, the listbox items ARE sorted.

So what I've done as a bandaid was to add another ListView on Tab(0) and hide
it behind something. Load my Text stuff to this and then dump it to my Tab(1)
ListView. And this works. A poor code way of doing it. But performance is
nothing as there is only <100 line items in the ListView.
foreach (<you data>)
{
ListViewItem item=new ListViewItem()
...
MyListViewItems.Add(item)
}

//This line of code sorts the ListView
MyListView.ListViewItemSorter=<myIComparer>


I'll check this out. As I'd rather not have two ListView's (simply bad coding
if for no other reason).

Thanks!

Bruce F
Jul 21 '05 #5

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

Similar topics

6
by: Anushya | last post by:
Hi I am using Listview and inherited listview control overriding WndProc & PreProcessMessage in ListView. I need this to customize listview to display only the page the user scrolls to. Since i...
2
by: tom | last post by:
Hey All- For those of you having troubles with listviews appearing in the wrong position when on a tab control, we've come up w/one other workaround that may be useful. When you move to the...
0
by: keith | last post by:
In a ListView control (two columns), I added a few ListView items. ListView listview=new ListView(); listview.Parent=this; listview.View=View.Details; listview.Columns.Add...
7
by: Dave Y | last post by:
I am a newbie to C# and am having trouble trying to override a ListView property method. I have created a new class derived from the Forms.Listview and I cannot figure out the syntax to override...
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...
4
by: Mr. B | last post by:
VB.net issue here. I've a strange event that I can't seem to figure out... On my Form, I've a TabControl (two Tabs)... On my first tab, I load an Ascii file and dump some info onto my...
2
by: Peter | last post by:
Hi, I have a problem with Listview using checkboxes. If i check items by code BEFORE the form is shown the Listview.Items are confused during the ItemChecked Event !!! After showing the...
4
by: Brian Gaze | last post by:
I have created a ListView control and have bound this to a datasource. Within the ItemTemplate of the ListView I have added another ListViewControl which is databound in the code behind. The idea...
3
by: RiZe | last post by:
Hi, I have a ListView on my server's GUI which is filled with connected clients data and I have to keep this data fresh. For example add new item for new client connection or remove item of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.