ListBox

kush28

New member
Joined
Nov 28, 2005
Messages
1
Programming Experience
Beginner
Hello there

i need some help

i have 2 forms, mainform, jobForm

On the mainform i have a listbox, lstBox1 and it has been populated with some items.

When i double click on one item inside the listbox it should open up jobform.
JobForm have 2 buttons, SAVE and CLOSE.

IF the user clicks on SAVE --> it should remove the item from the listbox.
IF the user clicks on CLOSE --> it shouldnot remove the item from the listbox.

Can someone please help me with this code.

Thanks
 
Please post in the most appropriate forum. Moved from VS.NET General to Windows Forms.

1. Handle the DoubleClick event of the ListBox.
2. Use the SelectedIndex or SelectedItem property of the ListBox to decide what data to send to the jobForm if necessary.
3. Display the jobForm by calling ShowDialog.
4. Assign DialogResult values to the two buttons. Yes and No or OK and Cancel would be the logical choices.
5. When DialogResult returns it will give you the DialogResult value of the Button that was pressed. Use this value to decide whether to delete the SelectedItem from the ListBox or not.

I suggest that you tackle these steps one at a time, not moving on to the next until the current is complete. If you have issues with a step then post a question back here. I'm not giving code because I suspect that this is homework.
 
jmcilhinney said:
2. Use the SelectedIndex or SelectedItem property of the ListBox to decide what data to send to the jobForm if necessary.
Better use ListBox.IndexFromPoint then SelectedIndex
jmcilhinney said:
I'm not giving code because I suspect that this is homework.
Er... there goes the example code I dutifully prepared and tested for this post . :D
 
Don Delegate said:
Better use ListBox.IndexFromPoint then SelectedIndex
Good point. I was thinking that the DoubleClick event wasn't raised if you clicked in an empty area but it's the ListView that behaves that way, not the ListBox.
Don Delegate said:
Er... there goes the example code I dutifully prepared and tested for this post . :D
I could be wrong.
 
Back
Top