Okay so the break down. I have a simple application. You can create a new vehicle, either a car, sports car, truck, or minivan. That object is then loaded into a listbox. Each one has 4 methods that display the message box (Start, Drive, Park, Wash). So if I create a 1992 Toyota Corolla, it's added into the listbox, but I'm trying to figure out a way to be able to select the Corolla in the listbox and then click a button to call the method and display the message box. Any ideas how I would go about this? I've tried just about everything I can think of, and Google and Bing were of no help at all.
salford6129
0
Newbie Poster
Recommended Answers
Jump to PostIn the design tab, double click the listbox. That'll start a sub routine stub for the
SelectedIndexChanged
event. When you make a selection in the listbox this event will fire and you can display your messagebox there. For instance:private void listBox1_SelectedIndexChanged(object sender, EventArgs e) …
Jump to PostUse GetSelectedItem to get the object, then just call the methods.
Jump to PostI think that you need to make things static so that they can be shared. But I'm not sure how that'll work with the abstract, override, and virtual modifiers you've got.
Jump to PostThey don't need to be static. Rarely do things need to be static.
Jump to PostMade some changes to your code. Not sure if they'll fit with what you'll need in the end, but you can access all of
automobile
's properties and methods from your form, just useVehicleClass.Automobile.
public class VehicleClass { // Abstract Class public abstract class …
All 19 Replies
tinstaafl
1,176
Posting Maven
salford6129
0
Newbie Poster
Momerath
1,327
Nearly a Senior Poster
Featured Poster
tinstaafl
1,176
Posting Maven
Momerath
1,327
Nearly a Senior Poster
Featured Poster
tinstaafl
1,176
Posting Maven
Momerath
1,327
Nearly a Senior Poster
Featured Poster
Momerath
1,327
Nearly a Senior Poster
Featured Poster
tinstaafl
1,176
Posting Maven
Momerath
1,327
Nearly a Senior Poster
Featured Poster
salford6129
0
Newbie Poster
salford6129
0
Newbie Poster
tinstaafl
1,176
Posting Maven
salford6129
0
Newbie Poster
salford6129
0
Newbie Poster
tinstaafl
1,176
Posting Maven
salford6129
0
Newbie Poster
tinstaafl
1,176
Posting Maven
salford6129
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.