Treeview background image

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?UGF0cmlja1M=?=

    Treeview background image

    I'd like to be able to give a treeview in my application a nice smooth
    gradient as a background image, but I'm having trouble doing this. Webpages
    that I've seen so far seem to suggest using the BackgroundImage property, but
    this does not seem to work. I'm using C# Express 2008.

    Does anybody here have any solutions?
  • =?Utf-8?B?RnJhbmsgVXJheQ==?=

    #2
    RE: Treeview background image

    I am using UltraTree from Infragistics,
    this works perfect.

    Best regards
    Frank

    "PatrickS" wrote:
    I'd like to be able to give a treeview in my application a nice smooth
    gradient as a background image, but I'm having trouble doing this. Webpages
    that I've seen so far seem to suggest using the BackgroundImage property, but
    this does not seem to work. I'm using C# Express 2008.
    >
    Does anybody here have any solutions?

    Comment

    • Peter Duniho

      #3
      Re: Treeview background image

      On Tue, 22 Jul 2008 03:34:00 -0700, PatrickS
      <msdn_newsgroup s001@_removetex tplusunderscore s_seurre.com.wr ote:
      I'd like to be able to give a treeview in my application a nice smooth
      gradient as a background image, but I'm having trouble doing this.
      Webpages
      that I've seen so far seem to suggest using the BackgroundImage
      property, but
      this does not seem to work. I'm using C# Express 2008.
      >
      Does anybody here have any solutions?
      Good question. :) BackgroundImage is public, but MSDN says it's for
      "framework use only" and I was unable to see any effect when setting it,
      nor was I able to get the OnPaint() or OnPaintBackgrou nd() methods to be
      called when I tried sub-classing TreeView. They seem to just be
      completely disabled.

      However, I was successful in overriding WndProc(), watching for the
      WM_PAINT or WM_ERASEBKGND messages and drawing a background image there (I
      added a public property to allow me to set the Image). If handling
      WM_PAINT, you can do it before calling the base.WndProc(), and if handling
      WM_ERASEBKGND, you can do it after calling base.WndProc(). Either
      approach seemed to work.

      I understand why the TreeView control might not actually use OnPaint() and
      OnPaintBackgrou nd() itself, but I was surprised that it doesn't even call
      those methods at all. That certainly seems odd to me. Looks like you
      need to go "old-school" to do this (and a warning: there's always a chance
      that doing so isn't going to work perfectly...I didn't test that option
      thoroughly).

      Pete

      Comment

      • =?Utf-8?B?UGF0cmlja1M=?=

        #4
        RE: Treeview background image

        Unfortunately I don't believe that spending the sort of money they appear to
        be asking for is an option.

        (and would be like taking a sledgehammer to a nut given that all I want to
        do that's out of the ordinary at this stage is set the background image and
        they only seem to be selling an entire suite of controls)

        "Frank Uray" wrote:
        I am using UltraTree from Infragistics,
        this works perfect.
        >
        Best regards
        Frank
        >
        "PatrickS" wrote:
        >
        I'd like to be able to give a treeview in my application a nice smooth
        gradient as a background image, but I'm having trouble doing this. Webpages
        that I've seen so far seem to suggest using the BackgroundImage property, but
        this does not seem to work. I'm using C# Express 2008.

        Does anybody here have any solutions?

        Comment

        • =?Utf-8?B?UGF0cmlja1M=?=

          #5
          Re: Treeview background image

          It seems that the following line of code will allow the BackgroundImage value
          to be respected:

          this.SetStyle(C ontrolStyles.Us erPaint, true);

          However now the nodes are not being displayed. It's as if the background is
          actually being displayed over them. I guess a bit of further investigation
          would not amiss. Thank you for the tip though.

          "Peter Duniho" wrote:
          On Tue, 22 Jul 2008 03:34:00 -0700, PatrickS
          <msdn_newsgroup s001@_removetex tplusunderscore s_seurre.com.wr ote:
          >
          I'd like to be able to give a treeview in my application a nice smooth
          gradient as a background image, but I'm having trouble doing this.
          Webpages
          that I've seen so far seem to suggest using the BackgroundImage
          property, but
          this does not seem to work. I'm using C# Express 2008.

          Does anybody here have any solutions?
          >
          Good question. :) BackgroundImage is public, but MSDN says it's for
          "framework use only" and I was unable to see any effect when setting it,
          nor was I able to get the OnPaint() or OnPaintBackgrou nd() methods to be
          called when I tried sub-classing TreeView. They seem to just be
          completely disabled.
          >
          However, I was successful in overriding WndProc(), watching for the
          WM_PAINT or WM_ERASEBKGND messages and drawing a background image there (I
          added a public property to allow me to set the Image). If handling
          WM_PAINT, you can do it before calling the base.WndProc(), and if handling
          WM_ERASEBKGND, you can do it after calling base.WndProc(). Either
          approach seemed to work.
          >
          I understand why the TreeView control might not actually use OnPaint() and
          OnPaintBackgrou nd() itself, but I was surprised that it doesn't even call
          those methods at all. That certainly seems odd to me. Looks like you
          need to go "old-school" to do this (and a warning: there's always a chance
          that doing so isn't going to work perfectly...I didn't test that option
          thoroughly).
          >
          Pete
          >

          Comment

          Working...