Triangular Shape Checkbox (ButtonStyle)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jess@aol.com

    #1

    Triangular Shape Checkbox (ButtonStyle)

    Is there a way to make a checkbox (button style) that is triangular
    shaped?
  • Cor Ligthert [MVP]

    #2
    Re: Triangular Shape Checkbox (ButtonStyle)

    Jess,

    You make mu curious, why?

    Cor

    <Jess@aol.comsc hreef in bericht
    news:cikmr2t838 14nei40s6qbe2nb qgudi7ft7@4ax.c om...
    Is there a way to make a checkbox (button style) that is triangular
    shaped?

    Comment

    • Jess@aol.com

      #3
      Re: Triangular Shape Checkbox (ButtonStyle)

      I wand to create a diamond shape button that has consists of a left
      right top and button segment (4 triangles) that toggles.


      On Sat, 27 Jan 2007 20:36:09 +0100, "Cor Ligthert [MVP]"
      <notmyfirstname @planet.nlwrote :
      >Jess,
      >
      >You make mu curious, why?
      >
      >Cor
      >
      ><Jess@aol.coms chreef in bericht
      >news:cikmr2t83 814nei40s6qbe2n bqgudi7ft7@4ax. com...
      >Is there a way to make a checkbox (button style) that is triangular
      >shaped?
      >

      Comment

      • rowe_newsgroups

        #4
        Re: Triangular Shape Checkbox (ButtonStyle)

        So does each segment toggle (i.e. four on/off boxes on each control)?

        If so here's one method you could use. You could just inherit the
        checkbox class and add a property that holds which position the
        triangle is in (left, right, top, or bottom). Then, in it's overriden
        paint method reference that property and draw the appropriate image
        based on the value it returns (I would use an enum and a switch
        statement) Then add four of this custom check box to your user
        control, set the new position property, and drag them to where you
        need them on the control. All that would be left is to create any
        properties you might need for the control.

        I hope that made since (it's getting pretty late here :-) )

        Thanks,

        Seth Rowe


        On Jan 27, 3:33 pm, J...@aol.com wrote:
        I wand to create a diamond shape button that has consists of a left
        right top and button segment (4 triangles) that toggles.
        >
        On Sat, 27 Jan 2007 20:36:09 +0100, "Cor Ligthert [MVP]"
        >
        <notmyfirstn... @planet.nlwrote :
        Jess,
        >
        You make mu curious, why?
        >
        Cor
        >
        <J...@aol.comsc hreef in bericht
        news:cikmr2t838 14nei40s6qbe2nb qgudi7ft7@4ax.c om...
        Is there a way to make a checkbox (button style) that is triangular
        shaped?

        Comment

        • Jess@aol.com

          #5
          Re: Triangular Shape Checkbox (ButtonStyle)

          I had tried this (decided I wanted a pie instead of a triangle) But
          the problem is that although it displays the pie you still see the
          outline of the square button. This is the code for 1 of the 4 buttons

          For the Class

          Public Class NewCheckBox2
          Inherits CheckBox
          Private CenterSquareCol or As Color = _
          Color.Red
          Private CenterSquareCol or2 As Color = _
          Color.Blue
          Protected Overrides Sub OnPaint( _
          ByVal pevent As System.Windows. Forms.PaintEven tArgs)
          Dim CenterSquare As New Rectangle(-15, -40, 90, 90)
          Me.FlatStyle = Windows.Forms.F latStyle.Flat
          'Me.Bounds
          MyBase.OnPaint( pevent)
          If Me.Checked Then
          pevent.Graphics .FillPie(New SolidBrush(Cent erSquareColor),
          CenterSquare, 45, 90)
          Else
          pevent.Graphics .FillPie(New
          SolidBrush(Cent erSquareColor2) , CenterSquare, Dim1, Dim2)
          End If
          End Sub
          End Class



          For the Form

          Public Class Form1
          Private Sub Form1_Load(ByVa l sender As System.Object, _
          ByVal e As System.EventArg s) Handles MyBase.Load
          Dim MyCheckBox2 As New NewCheckBox2
          With MyCheckBox2
          .Text = "Custom Colored Check Box"
          .Left = 125 ' OldCheckBox.Lef t
          .Top = 100 ' OldCheckBox.Top + OldCheckBox.Hei ght
          .Size = New Size(60, 60) ' OldCheckBox.Siz e
          .Appearance = Appearance.Butt on
          .BackColor = Color.Transpare nt
          .FlatStyle = FlatStyle.Flat
          .ForeColor = Color.Transpare nt
          End With
          Controls.Add(My CheckBox2)
          End Sub
          End Class




          On 27 Jan 2007 16:47:01 -0800, "rowe_newsgroup s"
          <rowe_email@yah oo.comwrote:
          >So does each segment toggle (i.e. four on/off boxes on each control)?
          >
          >If so here's one method you could use. You could just inherit the
          >checkbox class and add a property that holds which position the
          >triangle is in (left, right, top, or bottom). Then, in it's overriden
          >paint method reference that property and draw the appropriate image
          >based on the value it returns (I would use an enum and a switch
          >statement) Then add four of this custom check box to your user
          >control, set the new position property, and drag them to where you
          >need them on the control. All that would be left is to create any
          >properties you might need for the control.
          >
          >I hope that made since (it's getting pretty late here :-) )
          >
          >Thanks,
          >
          >Seth Rowe
          >
          >
          >On Jan 27, 3:33 pm, J...@aol.com wrote:
          >I wand to create a diamond shape button that has consists of a left
          >right top and button segment (4 triangles) that toggles.
          >>
          >On Sat, 27 Jan 2007 20:36:09 +0100, "Cor Ligthert [MVP]"
          >>
          ><notmyfirstn.. .@planet.nlwrot e:
          >Jess,
          >>
          >You make mu curious, why?
          >>
          >Cor
          >>
          ><J...@aol.coms chreef in bericht
          >news:cikmr2t83 814nei40s6qbe2n bqgudi7ft7@4ax. com...
          >Is there a way to make a checkbox (button style) that is triangular
          >shaped?

          Comment

          • Cor Ligthert [MVP]

            #6
            Re: Triangular Shape Checkbox (ButtonStyle)

            Jess,

            It absolute not my favorite sport, but to add something to Seth.

            Have a look at Region
            http://msdn2.microsoft.com/en-us/lib...ol.region.aspx

            As well think about radiobuttons inside a groupbox, they have in my idea
            more the behaviour you want and will in my idea even look nicer.

            Cor



            <Jess@aol.comsc hreef in bericht
            news:u56or2lpfr 15uusnugc4nipgv piumbcc5b@4ax.c om...
            >I had tried this (decided I wanted a pie instead of a triangle) But
            the problem is that although it displays the pie you still see the
            outline of the square button. This is the code for 1 of the 4 buttons
            >
            For the Class
            >
            Public Class NewCheckBox2
            Inherits CheckBox
            Private CenterSquareCol or As Color = _
            Color.Red
            Private CenterSquareCol or2 As Color = _
            Color.Blue
            Protected Overrides Sub OnPaint( _
            ByVal pevent As System.Windows. Forms.PaintEven tArgs)
            Dim CenterSquare As New Rectangle(-15, -40, 90, 90)
            Me.FlatStyle = Windows.Forms.F latStyle.Flat
            'Me.Bounds
            MyBase.OnPaint( pevent)
            If Me.Checked Then
            pevent.Graphics .FillPie(New SolidBrush(Cent erSquareColor),
            CenterSquare, 45, 90)
            Else
            pevent.Graphics .FillPie(New
            SolidBrush(Cent erSquareColor2) , CenterSquare, Dim1, Dim2)
            End If
            End Sub
            End Class
            >
            >
            >
            For the Form
            >
            Public Class Form1
            Private Sub Form1_Load(ByVa l sender As System.Object, _
            ByVal e As System.EventArg s) Handles MyBase.Load
            Dim MyCheckBox2 As New NewCheckBox2
            With MyCheckBox2
            .Text = "Custom Colored Check Box"
            .Left = 125 ' OldCheckBox.Lef t
            .Top = 100 ' OldCheckBox.Top + OldCheckBox.Hei ght
            .Size = New Size(60, 60) ' OldCheckBox.Siz e
            .Appearance = Appearance.Butt on
            .BackColor = Color.Transpare nt
            .FlatStyle = FlatStyle.Flat
            .ForeColor = Color.Transpare nt
            End With
            Controls.Add(My CheckBox2)
            End Sub
            End Class
            >
            >
            >
            >
            On 27 Jan 2007 16:47:01 -0800, "rowe_newsgroup s"
            <rowe_email@yah oo.comwrote:
            >
            >>So does each segment toggle (i.e. four on/off boxes on each control)?
            >>
            >>If so here's one method you could use. You could just inherit the
            >>checkbox class and add a property that holds which position the
            >>triangle is in (left, right, top, or bottom). Then, in it's overriden
            >>paint method reference that property and draw the appropriate image
            >>based on the value it returns (I would use an enum and a switch
            >>statement) Then add four of this custom check box to your user
            >>control, set the new position property, and drag them to where you
            >>need them on the control. All that would be left is to create any
            >>properties you might need for the control.
            >>
            >>I hope that made since (it's getting pretty late here :-) )
            >>
            >>Thanks,
            >>
            >>Seth Rowe
            >>
            >>
            >>On Jan 27, 3:33 pm, J...@aol.com wrote:
            >>I wand to create a diamond shape button that has consists of a left
            >>right top and button segment (4 triangles) that toggles.
            >>>
            >>On Sat, 27 Jan 2007 20:36:09 +0100, "Cor Ligthert [MVP]"
            >>>
            >><notmyfirstn. ..@planet.nlwro te:
            >>Jess,
            >>>
            >>You make mu curious, why?
            >>>
            >>Cor
            >>>
            >><J...@aol.com schreef in bericht
            >>news:cikmr2t8 3814nei40s6qbe2 nbqgudi7ft7@4ax .com...
            >>Is there a way to make a checkbox (button style) that is triangular
            >>shaped?
            >

            Comment

            • Mick Doherty

              #7
              Re: Triangular Shape Checkbox (ButtonStyle)

              This sounds like a custom control would be better suited to the task.

              I have outlined a very basic control below which you can expand upon to give
              you exactly what you want.
              For instance, you may like to add a Slices property to give you a collection
              of PieSlices instead of having a fixed array of 4 PieSlices.

              \\\
              Public Class CheckPie
              Inherits System.Windows. Forms.UserContr ol

              Protected Overrides ReadOnly Property DefaultSize() As Size
              Get
              Return New Size(48, 48)
              End Get
              End Property

              Private Slices() As PieSlice

              Private Class PieSlice
              Public Path As New Drawing2D.Graph icsPath
              Public Checked As Boolean
              Public Sub New()
              Me.Path = New Drawing2D.Graph icsPath
              End Sub
              End Class

              Public Sub New()
              MyBase.New()
              Me.SetStyle(Con trolStyles.Resi zeRedraw, True)
              Slices = New PieSlice() {New PieSlice, New PieSlice, _
              New PieSlice, New PieSlice}
              Me.OnResize(Eve ntArgs.Empty)
              End Sub

              Protected Overrides Sub OnResize(ByVal e As System.EventArg s)
              MyBase.OnResize (e)
              Dim r As Rectangle = Me.ClientRectan gle
              r.Width -= 1
              r.Height -= 1
              For id As Int32 = 0 To 3
              Slices(id).Path .Reset()
              Slices(id).Path .AddPie(r, 45 + (id * 90), 90)
              Next
              End Sub

              Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
              MyBase.OnPaint( e)
              If Slices.Length = 0 Then Return
              For Each slice As PieSlice In Slices
              If slice.Checked Then
              e.Graphics.Fill Path(Brushes.Re d, slice.Path)
              Else
              e.Graphics.Fill Path(Brushes.Bl ue, slice.Path)
              End If
              e.Graphics.Draw Path(Pens.Gray, slice.Path)
              Next
              End Sub

              Protected Overrides Sub OnClick(ByVal e As System.EventArg s)
              MyBase.OnClick( e)
              For Each slice As PieSlice In Slices
              Dim pt As Point = Me.PointToClien t(Me.MousePosit ion)
              If slice.Path.IsVi sible(pt.X, pt.Y) Then
              slice.Checked = Not slice.Checked
              Me.Invalidate(N ew Region(slice.Pa th))
              End If
              Next
              End Sub

              End Class
              ///

              --
              Mick Doherty
              Dotnetrix offers Nothing. Standard and Premium versions available.



              <Jess@aol.comwr ote in message
              news:u56or2lpfr 15uusnugc4nipgv piumbcc5b@4ax.c om...
              >I had tried this (decided I wanted a pie instead of a triangle) But
              the problem is that although it displays the pie you still see the
              outline of the square button. This is the code for 1 of the 4 buttons
              >
              For the Class
              >
              Public Class NewCheckBox2
              Inherits CheckBox
              Private CenterSquareCol or As Color = _
              Color.Red
              Private CenterSquareCol or2 As Color = _
              Color.Blue
              Protected Overrides Sub OnPaint( _
              ByVal pevent As System.Windows. Forms.PaintEven tArgs)
              Dim CenterSquare As New Rectangle(-15, -40, 90, 90)
              Me.FlatStyle = Windows.Forms.F latStyle.Flat
              'Me.Bounds
              MyBase.OnPaint( pevent)
              If Me.Checked Then
              pevent.Graphics .FillPie(New SolidBrush(Cent erSquareColor),
              CenterSquare, 45, 90)
              Else
              pevent.Graphics .FillPie(New
              SolidBrush(Cent erSquareColor2) , CenterSquare, Dim1, Dim2)
              End If
              End Sub
              End Class
              >
              >
              >
              For the Form
              >
              Public Class Form1
              Private Sub Form1_Load(ByVa l sender As System.Object, _
              ByVal e As System.EventArg s) Handles MyBase.Load
              Dim MyCheckBox2 As New NewCheckBox2
              With MyCheckBox2
              .Text = "Custom Colored Check Box"
              .Left = 125 ' OldCheckBox.Lef t
              .Top = 100 ' OldCheckBox.Top + OldCheckBox.Hei ght
              .Size = New Size(60, 60) ' OldCheckBox.Siz e
              .Appearance = Appearance.Butt on
              .BackColor = Color.Transpare nt
              .FlatStyle = FlatStyle.Flat
              .ForeColor = Color.Transpare nt
              End With
              Controls.Add(My CheckBox2)
              End Sub
              End Class
              >
              >
              >
              >
              On 27 Jan 2007 16:47:01 -0800, "rowe_newsgroup s"
              <rowe_email@yah oo.comwrote:
              >
              >>So does each segment toggle (i.e. four on/off boxes on each control)?
              >>
              >>If so here's one method you could use. You could just inherit the
              >>checkbox class and add a property that holds which position the
              >>triangle is in (left, right, top, or bottom). Then, in it's overriden
              >>paint method reference that property and draw the appropriate image
              >>based on the value it returns (I would use an enum and a switch
              >>statement) Then add four of this custom check box to your user
              >>control, set the new position property, and drag them to where you
              >>need them on the control. All that would be left is to create any
              >>properties you might need for the control.
              >>
              >>I hope that made since (it's getting pretty late here :-) )
              >>
              >>Thanks,
              >>
              >>Seth Rowe
              >>
              >>
              >>On Jan 27, 3:33 pm, J...@aol.com wrote:
              >>I wand to create a diamond shape button that has consists of a left
              >>right top and button segment (4 triangles) that toggles.
              >>>
              >>On Sat, 27 Jan 2007 20:36:09 +0100, "Cor Ligthert [MVP]"
              >>>
              >><notmyfirstn. ..@planet.nlwro te:
              >>Jess,
              >>>
              >>You make mu curious, why?
              >>>
              >>Cor
              >>>
              >><J...@aol.com schreef in bericht
              >>news:cikmr2t8 3814nei40s6qbe2 nbqgudi7ft7@4ax .com...
              >>Is there a way to make a checkbox (button style) that is triangular
              >>shaped?
              >

              Comment

              • Jess@aol.com

                #8
                Re: Triangular Shape Checkbox (ButtonStyle)

                THANX

                On Sun, 28 Jan 2007 11:39:49 -0000, "Mick Doherty"
                <EXCHANGE#WITH@ AND.REMOVE.SQUA REBRACKETS.[mdaudi100#ntlwo rld.com]>
                wrote:
                >This sounds like a custom control would be better suited to the task.
                >
                >I have outlined a very basic control below which you can expand upon to give
                >you exactly what you want.
                >For instance, you may like to add a Slices property to give you a collection
                >of PieSlices instead of having a fixed array of 4 PieSlices.
                >
                >\\\
                >Public Class CheckPie
                Inherits System.Windows. Forms.UserContr ol
                >
                Protected Overrides ReadOnly Property DefaultSize() As Size
                Get
                Return New Size(48, 48)
                End Get
                End Property
                >
                Private Slices() As PieSlice
                >
                Private Class PieSlice
                Public Path As New Drawing2D.Graph icsPath
                Public Checked As Boolean
                Public Sub New()
                Me.Path = New Drawing2D.Graph icsPath
                End Sub
                End Class
                >
                Public Sub New()
                MyBase.New()
                Me.SetStyle(Con trolStyles.Resi zeRedraw, True)
                Slices = New PieSlice() {New PieSlice, New PieSlice, _
                New PieSlice, New PieSlice}
                Me.OnResize(Eve ntArgs.Empty)
                End Sub
                >
                Protected Overrides Sub OnResize(ByVal e As System.EventArg s)
                MyBase.OnResize (e)
                Dim r As Rectangle = Me.ClientRectan gle
                r.Width -= 1
                r.Height -= 1
                For id As Int32 = 0 To 3
                Slices(id).Path .Reset()
                Slices(id).Path .AddPie(r, 45 + (id * 90), 90)
                Next
                End Sub
                >
                Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
                MyBase.OnPaint( e)
                If Slices.Length = 0 Then Return
                For Each slice As PieSlice In Slices
                If slice.Checked Then
                e.Graphics.Fill Path(Brushes.Re d, slice.Path)
                Else
                e.Graphics.Fill Path(Brushes.Bl ue, slice.Path)
                End If
                e.Graphics.Draw Path(Pens.Gray, slice.Path)
                Next
                End Sub
                >
                Protected Overrides Sub OnClick(ByVal e As System.EventArg s)
                MyBase.OnClick( e)
                For Each slice As PieSlice In Slices
                Dim pt As Point = Me.PointToClien t(Me.MousePosit ion)
                If slice.Path.IsVi sible(pt.X, pt.Y) Then
                slice.Checked = Not slice.Checked
                Me.Invalidate(N ew Region(slice.Pa th))
                End If
                Next
                End Sub
                >
                >End Class
                >///

                Comment

                • Jess@aol.com

                  #9
                  Re: Triangular Shape Checkbox (ButtonStyle)

                  Try the code and got the following warning

                  Public Sub New()' in designer-generated type 'Project1.Check Pie'
                  should call InitializeCompo nent method.

                  Not sure what this means








                  On Sun, 28 Jan 2007 11:39:49 -0000, "Mick Doherty"
                  <EXCHANGE#WITH@ AND.REMOVE.SQUA REBRACKETS.[mdaudi100#ntlwo rld.com]>
                  wrote:
                  >This sounds like a custom control would be better suited to the task.
                  >
                  >I have outlined a very basic control below which you can expand upon to give
                  >you exactly what you want.
                  >For instance, you may like to add a Slices property to give you a collection
                  >of PieSlices instead of having a fixed array of 4 PieSlices.
                  >
                  >\\\
                  >Public Class CheckPie
                  Inherits System.Windows. Forms.UserContr ol
                  >
                  Protected Overrides ReadOnly Property DefaultSize() As Size
                  Get
                  Return New Size(48, 48)
                  End Get
                  End Property
                  >
                  Private Slices() As PieSlice
                  >
                  Private Class PieSlice
                  Public Path As New Drawing2D.Graph icsPath
                  Public Checked As Boolean
                  Public Sub New()
                  Me.Path = New Drawing2D.Graph icsPath
                  End Sub
                  End Class
                  >
                  Public Sub New()
                  MyBase.New()
                  Me.SetStyle(Con trolStyles.Resi zeRedraw, True)
                  Slices = New PieSlice() {New PieSlice, New PieSlice, _
                  New PieSlice, New PieSlice}
                  Me.OnResize(Eve ntArgs.Empty)
                  End Sub
                  >
                  Protected Overrides Sub OnResize(ByVal e As System.EventArg s)
                  MyBase.OnResize (e)
                  Dim r As Rectangle = Me.ClientRectan gle
                  r.Width -= 1
                  r.Height -= 1
                  For id As Int32 = 0 To 3
                  Slices(id).Path .Reset()
                  Slices(id).Path .AddPie(r, 45 + (id * 90), 90)
                  Next
                  End Sub
                  >
                  Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
                  MyBase.OnPaint( e)
                  If Slices.Length = 0 Then Return
                  For Each slice As PieSlice In Slices
                  If slice.Checked Then
                  e.Graphics.Fill Path(Brushes.Re d, slice.Path)
                  Else
                  e.Graphics.Fill Path(Brushes.Bl ue, slice.Path)
                  End If
                  e.Graphics.Draw Path(Pens.Gray, slice.Path)
                  Next
                  End Sub
                  >
                  Protected Overrides Sub OnClick(ByVal e As System.EventArg s)
                  MyBase.OnClick( e)
                  For Each slice As PieSlice In Slices
                  Dim pt As Point = Me.PointToClien t(Me.MousePosit ion)
                  If slice.Path.IsVi sible(pt.X, pt.Y) Then
                  slice.Checked = Not slice.Checked
                  Me.Invalidate(N ew Region(slice.Pa th))
                  End If
                  Next
                  End Sub
                  >
                  >End Class
                  >///

                  Comment

                  • rowe_newsgroups

                    #10
                    Re: Triangular Shape Checkbox (ButtonStyle)

                    InitializeCompo nent() is a method that contains all the designer
                    generated code that is used for initializing the control. To
                    demonstrate, create a form and set a few properties and maybe add a
                    control or two. Then in the solution explorer, click the button at top
                    that shows everything. Then expand the newly created form's node and
                    open the Form.Designer.v b file. In that code file should be the
                    InitializeCompo nent method, you might have to expand the #Region
                    sections first in order to find the sub though. In that method you
                    will see the code that is generated for each change you made in the
                    designer.

                    The reason you (normally) need do call the InitializeCompo nent method
                    first is that it responsible for instantiating the objects. If you
                    need to call InitializeCompo nent but don't, then every time you try to
                    reference a designer added component you will get a
                    NullReferenceEx ception, since none of the objects were ever created.
                    However, if you handle all the instantiation/initialization somewhere
                    else in your code then you can completely ignore having to use the
                    InitializeCompo nent sub. For
                    compliance to the standards, or to get rid of the warning, you may
                    just want to write your initialization code in a method called
                    InitializeCompo nent. It's completely up to you.

                    Hope that helps.

                    Thanks,

                    Seth Rowe


                    On Jan 28, 12:44 pm, J...@aol.com wrote:
                    Try the code and got the following warning
                    >
                    Public Sub New()' in designer-generated type 'Project1.Check Pie'
                    should call InitializeCompo nent method.
                    >
                    Not sure what this means
                    >
                    On Sun, 28 Jan 2007 11:39:49 -0000, "Mick Doherty"
                    <EXCHANGE#W...@ AND.REMOVE.SQUA REBRACKETS.[mdaudi100#ntlwo rld.com]>
                    wrote:
                    >
                    This sounds like a custom control would be better suited to the task.
                    >
                    I have outlined a very basic control below which you can expand upon to give
                    you exactly what you want.
                    For instance, you may like to add a Slices property to give you a collection
                    of PieSlices instead of having a fixed array of 4 PieSlices.
                    >
                    \\\
                    Public Class CheckPie
                    Inherits System.Windows. Forms.UserContr ol
                    >
                    Protected Overrides ReadOnly Property DefaultSize() As Size
                    Get
                    Return New Size(48, 48)
                    End Get
                    End Property
                    >
                    Private Slices() As PieSlice
                    >
                    Private Class PieSlice
                    Public Path As New Drawing2D.Graph icsPath
                    Public Checked As Boolean
                    Public Sub New()
                    Me.Path = New Drawing2D.Graph icsPath
                    End Sub
                    End Class
                    >
                    Public Sub New()
                    MyBase.New()
                    Me.SetStyle(Con trolStyles.Resi zeRedraw, True)
                    Slices = New PieSlice() {New PieSlice, New PieSlice, _
                    New PieSlice, New PieSlice}
                    Me.OnResize(Eve ntArgs.Empty)
                    End Sub
                    >
                    Protected Overrides Sub OnResize(ByVal e As System.EventArg s)
                    MyBase.OnResize (e)
                    Dim r As Rectangle = Me.ClientRectan gle
                    r.Width -= 1
                    r.Height -= 1
                    For id As Int32 = 0 To 3
                    Slices(id).Path .Reset()
                    Slices(id).Path .AddPie(r, 45 + (id * 90), 90)
                    Next
                    End Sub
                    >
                    Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
                    MyBase.OnPaint( e)
                    If Slices.Length = 0 Then Return
                    For Each slice As PieSlice In Slices
                    If slice.Checked Then
                    e.Graphics.Fill Path(Brushes.Re d, slice.Path)
                    Else
                    e.Graphics.Fill Path(Brushes.Bl ue, slice.Path)
                    End If
                    e.Graphics.Draw Path(Pens.Gray, slice.Path)
                    Next
                    End Sub
                    >
                    Protected Overrides Sub OnClick(ByVal e As System.EventArg s)
                    MyBase.OnClick( e)
                    For Each slice As PieSlice In Slices
                    Dim pt As Point = Me.PointToClien t(Me.MousePosit ion)
                    If slice.Path.IsVi sible(pt.X, pt.Y) Then
                    slice.Checked = Not slice.Checked
                    Me.Invalidate(N ew Region(slice.Pa th))
                    End If
                    Next
                    End Sub
                    >
                    End Class
                    ///

                    Comment

                    • Mick Doherty

                      #11
                      Re: Triangular Shape Checkbox (ButtonStyle)

                      It just means that you added a UserControl to the project which also adds a
                      Partial class and auto-generated code, whereas I added a Class so didn't get
                      any extras.

                      In Sub New() just replace
                      MyBase.New()
                      with
                      InitializeCompo nent()

                      I also put
                      Me.PointToClien t(Me.MousePosit ion)
                      in OnClick() but it should have been
                      Me.PointToClien t(Control.Mouse Position)

                      --
                      Mick Doherty
                      Dotnetrix offers Nothing. Standard and Premium versions available.



                      <Jess@aol.comwr ote in message
                      news:tampr250jj bdh60l9l98jb5cl 99721pif0@4ax.c om...
                      Try the code and got the following warning
                      >
                      Public Sub New()' in designer-generated type 'Project1.Check Pie'
                      should call InitializeCompo nent method.
                      >
                      Not sure what this means
                      >

                      Comment

                      Working...