473,466 Members | 1,381 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

how to use radio buttons to sort in listview

2 New Member
Hi experts and all, I have encountered and in need of some help with checkboxes and listview. Just started to learn vs05 programming. This is my first thread by the way...

I want to sort out the data (as shown in the attachment) by using the check boxes and the listview and i am really stuck. For the list view, I am using an access file to read the data,

So can anyone help me. Really appreciate for any help/advices
Attached Files
File Type: zip pic.zip (26.3 KB, 101 views)
Aug 8 '08 #1
2 2048
cloud255
427 Recognized Expert Contributor
hi,

Apologies for the earlier post, please ignore it, i was being an idiot.

ok this should be more helpful:

your data bindings seem ok.

the syntax for sorting a list view seems a bit strange to me, anywy here it is:

first you have to specify a sorting metod,

Expand|Select|Wrap|Line Numbers
  1. listView1.Columns["ColumnName"].ListView.Sorting = SortOrder.Ascending;
then you can tell the control to sort on that column,

Expand|Select|Wrap|Line Numbers
  1. listView1.Columns["ColumnName"].ListView.Sort();
so use a string which gets a value from a swith to give it the name of the column which you want to sort

then replace "ColumnName" with the string variable,

that sould work.

do this after you have added all your items to the listview.

hope this works...
Aug 8 '08 #2
melvados
2 New Member
Hi there, really appreciate for your reply. Could you explain to me in a more detailed yet easier manner?

Also by the way, my list view is populated from the access file where I have write it in this manner and I don't seem to be using any datagridview...
Expand|Select|Wrap|Line Numbers
  1. Private Sub LoadProjects()
  2.         'Declare variables
  3.         Dim objListViewItem As ListViewItem
  4.  
  5.         'Initialize a new instance of the data access base class
  6.         Using objData As New WDABase
  7.             Try
  8.                 'Get all projects in a DataReader object
  9.                 objData.SQL = "usp_SelectProjects"
  10.                 objData.InitializeCommand()
  11.                 objData.OpenConnection()
  12.                 objData.DataReader = objData.Command.ExecuteReader
  13.  
  14.                 'See if any data exists before continuing
  15.                 If objData.DataReader.HasRows Then
  16.  
  17.                     'Clear previous list
  18.                     lvwParts.Items.Clear()
  19.  
  20.                     'Process all rows
  21.                     While objData.DataReader.Read()
  22.  
  23.                         'Create a new ListViewItem
  24.                         objListViewItem = New ListViewItem
  25.  
  26.                         'Add the data to the ListViewItem
  27.                         objListViewItem.Text = _
  28.                             objData.DataReader.Item("PartName")
  29.                         objListViewItem.Tag = objData.DataReader.Item("PartID")
  30.  
  31.                         'Add the sub items to the listview item
  32.                         objListViewItem.SubItems.Add( _
  33.                             objData.DataReader.Item("PartCode"))
  34.                         objListViewItem.SubItems.Add( _
  35.                             objData.DataReader.Item("SequenceNumber"))
  36.                         objListViewItem.SubItems.Add( _
  37.                             Format(objData.DataReader.Item("LastUpdateDate"), "g"))
  38.  
  39.                         'Add the ListViewItem to the ListView control
  40.                         lvwParts.Items.Add(objListViewItem)
  41.  
  42.                     End While
  43.  
  44.                 End If
  45.  
  46.                 objData.DataReader.Close()
  47.             Catch ExceptionErr As Exception
  48.                 MessageBox.Show(ExceptionErr.Message, strAppTitle)
  49.             End Try
  50.         End Using
  51.  
  52.         'Cleanup
  53.         objListViewItem = Nothing
  54.  
  55.     End Sub
  56.  
Could it still worked in this way from the code you given?
Am really sorry about this inconvenience, for I am just starting out.
Aug 8 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Verner Vaz | last post by:
Select Email ID based on 'a' selected radio button Hello there, I have a simple form with some fields to be filled in and when submitted is emailed to a couple of email ID. Now, this form...
4
by: Oscar Monteiro | last post by:
I Have to sets of Radio buttons like so: <input type="radio" name=p1 value=1> <input type="radio" name=p1 value=2> <input type="radio" name=p1 value=3> <br> <input type="radio" name=p2 value=1>...
6
by: Craig Keightley | last post by:
I have a page that has n number of radio groups (yes/No) how can i prevent the form being submitted if more than one radio group is not selected? By default all radio groups are unchecked ...
2
by: James P. | last post by:
Help, I need to display radio buttons on a form. The data is from SQL table: each row in each table is displayed as a radio button. I have multiple SQL tables so I understand I need to put...
5
by: swatidesai0407 | last post by:
hi im validating radio buttons i create dis radio button in php based on some how many records of my query. i wrote a javascript to validate this buttons. wat i do is dat wen no radio button...
2
by: dpazza | last post by:
Hi, I'm creating a quiz on using a form in VB 2005 express. I have four sets of questions and answers (labels and radio buttons) and I change between which set of questions is currently shown on...
1
by: Ian Toltz | last post by:
I'm working on a "pokédex" for people who play Pokémon. I need to have a list of all the pokémon, along with a set of radiobuttons for each. I've initially tried a ListView control, with the...
2
by: mckurban | last post by:
Hi All, I'm not very familiar with Javascript and need help with setting up some javascript code to allow users to create dynamic radio buttons from text field and then to use selected radio value...
3
by: Steve Swift | last post by:
I have a page containing: <FORM NAME=radios> <INPUT TYPE=RADIO NAME=RAD VALUE=1 ID=RAD1> <LABEL FOR=RAD1>Check One</LABEL> <A onClick="document.radios.RAD.checked=false; return false">Uncheck...
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
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...
0
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,...
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,...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

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.