I have开发者_开发问答 a project in c# windows Forms with a draw area in which I have different shapes. I want when I click the right click on one of them to show me a menu where I can add a description. After I press enter the text to be displayed next to the shape that I selected. Can somebody tell me?
As you draw your shapes, use Graphics.DrawString
to draw the text. http://msdn.microsoft.com/en-us/library/system.drawing.graphics.drawstring.aspx
If I understand correctly you need the user to enter the text and when pressing Enter, the description is applied to the shape. To do this you may create a TextBox control and place it where the user right-clicked. Then you should handle OnKeyUp event of the control to detect Enter key and may be consider handling OnLeave event in case the user clicks out of the TextBox and get the value and paint it using Graphics.DrawString as @Felice said.
精彩评论