Using DialogResult for Label

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sajjadlove
    New Member
    • Apr 2009
    • 19

    Using DialogResult for Label

    Hi
    i am using a label instead of a button control and now i want to use from DialogResult in my class...
    Code:
        public class GA5_Button : System.Windows.Forms.Label
        {
            [Browsable(true),
            DefaultValue(typeof(System.Windows.Forms.DialogResult))]
            public System.Windows.Forms.DialogResult DialogResult
            {
                get;
                set;
            }
    
        }
    how can i use from new DialogResult in my project to work correct???


    -----
    Sorry for bad english
    Thanks
  • tlhintoq
    Recognized Expert Specialist
    • Mar 2008
    • 3532

    #2
    Your class needs to inherit from a Dialog so it has all the same base events and so on.

    Comment

    • sajjadlove
      New Member
      • Apr 2009
      • 19

      #3
      My class inherit from Label.how can it inherits from Dialog??
      Do you can give me an example???

      Comment

      • tlhintoq
        Recognized Expert Specialist
        • Mar 2008
        • 3532

        #4
        A DialogResult comes from the Dialog class. You aren't going to make a label that inherits from a Dialog. If you want a DialogResult then you need to make a custom Dialog form that inherits from Dialog.

        In order to receive a DialogResult you need to open a Dialog form (or one that inherits from it)

        DialogResult = new myCustomDialog. ShowDialog();

        A label just isn't going to cut it. Though you could give your label some other event that you can watch for.

        Two tutorials that might help you with events and control inheritance:
        Custom events - A practical guide
        Buiding an application - Part 1

        Comment

        Working...