borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (Serial Mouse)Next Topic (Vertical scroll bar.) New Topic New Poll Post Reply
AndreaVB Forum : VB General : Control Required
Poster Message
niyati
Level: Scholar

Registered: 01-02-2006
Posts: 35

icon Control Required

Hello
I am doing a project in Vb 6.0 with microsoft acccess as the backend.
Here i have a database including a table named:Table_Of_Weightage in which i have two fields
Rem_Abbr       Rem_Weight
Ars                  0
Act-r                10
Gels                 2
Bov                  1

Through my coding of one form i am modifying the data of Rem_Weight field,like shown above.
Now the main thing which i am supposed to do is:
After updation of the weightages of the medicines i am simultaneously supposed to display the fields
Rem_Abbr along with their corresponding Rem_Weight values in a separate form.

I thought of using a listbox like this
frmremedies.lstdetails.AddItem adoRecWeight!Rem_Abbr & "----" & adoRecWeight!Rem_Weight
the entire thing is being displayed step by step but the problem is in the longer run
all the data is going to be unsorted still as it is above.
I want to display these two fields in such a way that incase towards the end i want the remedies to be sorted according to their weightages in descending or ascending order they should be sorted out on basis of the Rem_Weight field and not the abbreviations.
Is there any other control which i can use?
Would a listview be appropriate??
I am not well accutomed with VB so don't even know the working of a listview control.
Any other method by which i can solve my problem?
Please reply as soon as possible.
niyati

19-02-2006 at 01:14 PM
View Profile Send Email to User Show All Posts | Quote Reply
yronium
Level: Moderator


Registered: 14-04-2002
Posts: 907
icon Re: Control Required

Hello. I didn't understand: is the Abbr field in relation with another lookup table?
Anyway, there's nothing wrong using the listbox control. The steps, assuming that you use ADO, are like following:
- load a recordset
- sort it (this sorting has to be done on the recordset because you load a built string into the listbox), by the Sort property
- for each record you build a string with the Abbr value and the Rem value
- add the string to the listbox by the AddNew method
- (Important) set a number for each string by the ItemData property. This property is useful to set an ID to each list item, and you can set it by, after the lstMyList.AddNew itemstring method, an instruction like lstMyList.ItemData(lstMyList.NewIndex) = ID
- later you can read the ItemData property in the Click event, and choose a record in the table according with the selected item.

You can even use a DataList/DataCombo control instead. These controls are designed to work with a recordset and expose some more useful properties to bind them to the tables. The bad news is that they don't work in unbound mode, so if you want to do it you should use the common Listbox control. But I'd use it anyway: it's the first control you chose, so you are looking for something like it, and I think the best way is to make it work. Since I discovered the ItemData property I definitely chose to use listboxes and combos in my db-based projects.

Hope is clear. If you need some more info, tell us.

____________________________
Real Programmer can count up to 1024 on his fingers

20-02-2006 at 07:56 AM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : VB General : Control Required
Previous Topic (Serial Mouse)Next Topic (Vertical scroll bar.) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder