Selecting a PictureBox

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Fao, Sean

    Selecting a PictureBox

    I'm working on a Windows application (VS 2005) that I will need to be
    able to select images I've added to a FlowLayoutPanne l. I was
    attempting to select the various PictureBoxes and noticed that it wasn't
    working. Reading through the MSDN to find out why, I ran across the
    following:

    "The PictureBox is not a selectable control, which means that it cannot
    receive input focus."

    This obviously puts a damper on the project. Is there any workaround or
    alternative image controls that can be selected?

    Thank you in advance,

    --
    Sean
  • Ignacio Machin \( .NET/ C# MVP \)

    #2
    Re: Selecting a PictureBox

    Hi,

    Can you use a ImageButton instead?


    --
    --
    Ignacio Machin,
    ignacio.machin AT dot.state.fl.us
    Florida Department Of Transportation


    "Fao, Sean" <enceladus311@y ahoo.comI-WANT-NO-SPAMwrote in message
    news:OC1Xhnp0GH A.2196@TK2MSFTN GP03.phx.gbl...
    I'm working on a Windows application (VS 2005) that I will need to be able
    to select images I've added to a FlowLayoutPanne l. I was attempting to
    select the various PictureBoxes and noticed that it wasn't working.
    Reading through the MSDN to find out why, I ran across the following:
    >
    "The PictureBox is not a selectable control, which means that it cannot
    receive input focus."
    >
    This obviously puts a damper on the project. Is there any workaround or
    alternative image controls that can be selected?
    >
    Thank you in advance,
    >
    --
    Sean

    Comment

    • JustinC

      #3
      Re: Selecting a PictureBox

      It's somewhat of a hack, but could you place a transparent panel over
      the PictureBox and wire it's focus received event to your underlying
      picturebox?

      Ignacio Machin ( .NET/ C# MVP ) wrote:
      Hi,
      >
      Can you use a ImageButton instead?
      >
      >
      --
      --
      Ignacio Machin,
      ignacio.machin AT dot.state.fl.us
      Florida Department Of Transportation
      >
      >
      "Fao, Sean" <enceladus311@y ahoo.comI-WANT-NO-SPAMwrote in message
      news:OC1Xhnp0GH A.2196@TK2MSFTN GP03.phx.gbl...
      I'm working on a Windows application (VS 2005) that I will need to be able
      to select images I've added to a FlowLayoutPanne l. I was attempting to
      select the various PictureBoxes and noticed that it wasn't working.
      Reading through the MSDN to find out why, I ran across the following:

      "The PictureBox is not a selectable control, which means that it cannot
      receive input focus."

      This obviously puts a damper on the project. Is there any workaround or
      alternative image controls that can be selected?

      Thank you in advance,

      --
      Sean

      Comment

      • Bruce Wood

        #4
        Re: Selecting a PictureBox


        Fao, Sean wrote:
        I'm working on a Windows application (VS 2005) that I will need to be
        able to select images I've added to a FlowLayoutPanne l. I was
        attempting to select the various PictureBoxes and noticed that it wasn't
        working. Reading through the MSDN to find out why, I ran across the
        following:
        >
        "The PictureBox is not a selectable control, which means that it cannot
        receive input focus."
        >
        This obviously puts a damper on the project. Is there any workaround or
        alternative image controls that can be selected?
        In .NET 1.1 I wrote my own image gallery control that allows the user
        to select images. Although the PictureBox can't be selected as such, it
        can receive Click and DoubleClick events, and I just redraw the picture
        with a colour wash to indicate that it is the currently selected
        picture. In fact, I use two colours: one for "selected" and one for
        "checked".

        So... you can do it; you just have to "roll your own," as it were.

        Comment

        • senfo

          #5
          Re: Selecting a PictureBox

          Ignacio Machin ( .NET/ C# MVP ) wrote:
          Can you use a ImageButton instead?
          I'm actually doing this in a Windows application, which does not have an
          ImageButton control like ASP.NET does (at least not that I know of).
          You did, however, give me an idea. The Windows Button control *does*
          have an Image property, which, for some reason, I never thought about
          looking for.

          At first glance, it appears that the Image property will provide the
          functionality that I require.

          Thank you very much for your help,

          --
          Sean

          Comment

          • senfo

            #6
            Re: Selecting a PictureBox

            Bruce Wood wrote:
            In .NET 1.1 I wrote my own image gallery control that allows the user
            to select images. Although the PictureBox can't be selected as such, it
            can receive Click and DoubleClick events, and I just redraw the picture
            with a colour wash to indicate that it is the currently selected
            picture. In fact, I use two colours: one for "selected" and one for
            "checked".
            >
            So... you can do it; you just have to "roll your own," as it were.
            >
            I was fighting this approach because I was convinced there must be
            another way (I've often looked back on code I've written and realized
            how much easier the problem actually was since I learned more). At any
            rate, the Button just wasn't providing the functionality I was after, so
            I ended up extending the PictureBox class to fit my intended design.

            After all this fighting of the urge, you inspired me to give a try.
            Turns out it took me no more than 30 minutes or so to get everything
            done. I would have been further ahead if I had done this from the
            beginning!

            Thank you very much for the inspiration!

            --
            Sean

            Comment

            Working...