Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. how add a [property] as dialogbox

how add a [property] as dialogbox

Scheduled Pinned Locked Moved C#
questioncsharpcssvisual-studio
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Susuko
    wrote on last edited by
    #1

    I need to create a property for my custom control visible in visual studio property grid. But if i click on in it open a openfiledialog to serch a path as BackgroundImage for a picturebox. How can i do? I've tryed with [Browsable(true)] but it doesn't work.

    O 1 Reply Last reply
    0
    • S Susuko

      I need to create a property for my custom control visible in visual studio property grid. But if i click on in it open a openfiledialog to serch a path as BackgroundImage for a picturebox. How can i do? I've tryed with [Browsable(true)] but it doesn't work.

      O Offline
      O Offline
      Office Lineman
      wrote on last edited by
      #2

      Use a filtered UI Type Editor:

      ...

      // Reference: System.Design.dll
      using System.Drawing.Design;
      using System.Windows.Forms.Design;

      ...

      internal class MyFileNameEditor : FileNameEditor
      {
      protected override void InitializeDialog(OpenFileDialog openFileDialog)
      {
      base.InitializeDialog (openFileDialog);
      openFileDialog.Filter = "JPEG Files (*.jpg)|*.jpg|All Files (*.*)|*.*";
      }
      }

      ...

      [EditorAttribute(typeof(MyFileNameEditor), typeof(UITypeEditor))]
      public string PictureBoxBackgroundImage
      {
      get { return m_bgImagePath; }
      set
      {
      m_bgImagePath = value;
      Image bgImage = Image.FromFile(m_bgImagePath);
      // should do some Image creation error checking here
      this.thePictureBox.BackgroundImage = bgImage;
      }
      }

      -- I've killed again, haven't I?

      S 1 Reply Last reply
      0
      • O Office Lineman

        Use a filtered UI Type Editor:

        ...

        // Reference: System.Design.dll
        using System.Drawing.Design;
        using System.Windows.Forms.Design;

        ...

        internal class MyFileNameEditor : FileNameEditor
        {
        protected override void InitializeDialog(OpenFileDialog openFileDialog)
        {
        base.InitializeDialog (openFileDialog);
        openFileDialog.Filter = "JPEG Files (*.jpg)|*.jpg|All Files (*.*)|*.*";
        }
        }

        ...

        [EditorAttribute(typeof(MyFileNameEditor), typeof(UITypeEditor))]
        public string PictureBoxBackgroundImage
        {
        get { return m_bgImagePath; }
        set
        {
        m_bgImagePath = value;
        Image bgImage = Image.FromFile(m_bgImagePath);
        // should do some Image creation error checking here
        this.thePictureBox.BackgroundImage = bgImage;
        }
        }

        -- I've killed again, haven't I?

        S Offline
        S Offline
        Susuko
        wrote on last edited by
        #3

        very very tnx! sorry if i've not answer you before.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups