I have picture boxes added to a FlowLayout panel and a ContextMenu strip (associated with picture boxes) with 'Add description' item.
When I right click on a PictureBox and select 'Add description', a new form pops with large preview of the picture and a text box to write the description.
How can I preserve the text written by the user on the new form, after it’s closed, so if user wants to edit the description, he doesn’t have to type it from scratch again?
I figured I’d have to store the description somewhere and load it into the form when user clicks on the same picture again, but how can I know what picture he clicked on?
There is probably a smarter way to go about this, but I can’t think of one right now, so I hope you guys can help me.
You should be able to make use of
Tagproperty to hold the picture description info.As for to identify the
PictureBoxon context you can make use ofMouseEnterevent. Basically Define a class levelPictureBoxvariable (PictureBoxOnContext).Then you can add a
MouseEnterevent handler to thePictureBoxinstance and cast thesenderto aPictureBoxand assign it to thePictureBoxOnContextvariable.when you right click on the
PictureBox,MouseEnteris already triggered and the relavantPictureBoxis selected into thePictureBoxOnContextvariable.Then on the ‘Add description’ context menu click you can check if
PictureBoxOnContext != nulland pass this to the preview form.(rest you should be able to figure out; probably making use of delegates to pass back the information to parent form)