473,718 Members | 2,060 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 1842
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
2626
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 listview. So now trying to list only the page user scrolls to.
2
5306
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
2225
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
6448
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 I need to do in a different way this would just make everything significantly cleaner and eaasier...
7
15000
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 to programmatically get the data from the dataset table
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
6829
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
4510
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 selected row. I did something similar with a gridview control previously, but want to be able to...
3
2790
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 socket. Clients is a Hashtable filled * by instances of Client class (HT Key is (Double)Id,...
0
8827
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9358
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9121
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
9053
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7991
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5971
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3182
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2559
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2123
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.