The ProgrammersTalk Community
Forum Register Search Today's Posts Mark Forums Read
Register

Go Back   The ProgrammersTalk Community > General Programming > C#


Welcome to the The ProgrammersTalk Community forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.
Reply
 
LinkBack Thread Tools    Display Modes   
  #1 (permalink)  
Old 09-08-2007, 05:10 PM
TeraTask's Avatar
TeraTask TeraTask is offline
PT Admin
Awards Showcase
Quality Tutorial Quality Tutorial Quality Tutorial 
Total Awards: 3
Join Date: Jun 2007
Location: Reno, NV
Posts: 440
iTrader: (0)
TeraTask is a splendid one to beholdTeraTask is a splendid one to beholdTeraTask is a splendid one to beholdTeraTask is a splendid one to beholdTeraTask is a splendid one to beholdTeraTask is a splendid one to behold
Implementation Methodologies

I'm building a fairly complex application and it's been awhile since I've built any desktop apps. Here's the issue I'm currently facing. I have a number of objects I've modeled and interfaces which need to manage the associations. The problem is that form controls don't allow a key to be associated with a particular line and I'm wondering how you all manage that.

For example, let's say that I was collecting information on computer suppliers. For each of the computers I have I may have a number of vendors with their own details. The way I have the form setup is to have a ListBox with all the computers listed and when you click on the computer name, it shows the current list of vendors, allowing you to add them as well. Each computer is assigned a unique identifier, but there's no direct way of associating the unique identifier with the row in the ListBox so that I can then cross-reference the vendors by the computer id.

How do you all work around such a problem?

Oh, I should add that sometimes a sortable control is used (where the user can click and sort in the interface, not manually sorted via code) and I'd need to maintain any associations.

__________________
Jeremy Miller
Content Farmer - Optimized Automated Blog Posting

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
  #2 (permalink)  
Old 09-08-2007, 11:37 PM
TeraTask's Avatar
TeraTask TeraTask is offline
PT Admin
Awards Showcase
Quality Tutorial Quality Tutorial Quality Tutorial 
Total Awards: 3
Join Date: Jun 2007
Location: Reno, NV
Posts: 440
iTrader: (0)
TeraTask is a splendid one to beholdTeraTask is a splendid one to beholdTeraTask is a splendid one to beholdTeraTask is a splendid one to beholdTeraTask is a splendid one to beholdTeraTask is a splendid one to behold
Found the answer, so I thought I'd share it, briefly:

1) Create an object for the item you want to list in the listbox. Allow this object to contain the primary key as well as a ToString() function. The ToString() function should return the text to be displayed in the listbox.

2) Create an array of instances of the object from #1.

3) Set the datasource of the listbox to the array created in #2.

4) Add/Delete/Modify the array from #2 by calling the primary key of the selected object (which will be of the object type and not a string as normal).

5) Set the listbox datasource to null.

6) Set the listbox datasource to the array from #2.

Steps 5 and 6 are necessary because array's don't update the listbox that they have changed (there's some event missing there, but I don't recall what it's called), but changing the source to null and then back to the datasource triggers a full update. Skipping step 6 doesn't cue the language into the fact that the source has changed.

Hope this helps someone else!

__________________
Jeremy Miller
Content Farmer - Optimized Automated Blog Posting

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
The Following 2 Users Say Thank You to TeraTask For This Useful Post:
Bench (09-09-2007), HelloWorld (09-09-2007)
Reply


Thread Tools
Display Modes

   Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -7. The time now is 04:08 PM. Powered by vBulletin
Copyright © 2000 - 2007, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO © 2007 ProgrammersTalk Sedo - Buy and Sell Domain Names and Websites project info: programmerstalk.net Statistics for project programmerstalk.net etracker® web controlling instead of log file analysis


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50