473,569 Members | 2,782 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1829
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_Cli ck(ByVal eventSender As System.Object, ByVal
eventArgs As System.EventArg s) Handles TabControl1.Cli ck
' Do Things Based on Active Tab Selected

If TabControl1.Tab Pages(0).Focus( ) = True Then
btnAddTabs.Enab led = False
btnModTabs.Enab led = False
btnDelTabs.Enab led = False
lblDwgsDelete.T ext = "0"
lblDwgsAdded.Te xt = "0"
txbDwgRename.Te xt = ""
lblDwgRename.Te xt = ""
cmbAddDwgTabs.S electedIndex = 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 ListViewItemSor ter 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.List ViewItemSorter= <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 ListViewItemSor ter in that
event handler, which you did not according to your reply to the other post.

"Mr. B" <Us**@NoWhere.c om> wrote in message
news:ge******** *************** *********@4ax.c om...
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*****@NotRea l.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 ListViewItemSor ter 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.Lis tViewItemSorter =<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
2616
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 am populating listview with more than 200,000 items. It is too slow and tried virtual listview. But that doesnot allow me to add images in the...
2
5304
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 tab page containing the listview (tab's onChange event), fire off your form timer by setting the timer interval (me.timerinterval = 1)
0
2215
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 ("Col1",200,HorizontalAlignment.Left); listview.Columns.Add ("Col2",800,HorizontalAlignment.Left);
7
6426
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 ListView.Items.Add(), . I see that it is a virtual method so it should be easy to do. If anyone can help I would appreciate it greatly. I can do what...
7
14964
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 MyList data is resident in a dataset table. I'm stuck and can't choose either because. If I choose ListView as my control I don't understand how...
4
254
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 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
2
6816
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 form every thing works fine: checking items by code
4
4490
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 is that when clicking on the "Show details" button the ListView for the appropriate row binds in the codebehind and displays the detail data for the...
3
2783
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 disconnected client etc. I wrote this: /** * This fills the ListView with new data. Client is class with getter of * IP adress, client's ID, name and...
0
7605
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7917
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8118
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7665
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7962
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6277
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5501
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3631
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1207
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.