473,383 Members | 1,843 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,383 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 1807
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.