473,408 Members | 2,477 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

How do I capture the paint event on a treeview?

I'm trying to adjust the length of the strings being drawn, as well as
some effects depending on what item is actually being drawn. I tried
doing the following, but the paint event never runs:
#region TView
public class tView : TreeView
{
#region Constructor
public tView()
{
Paint += new PaintEventHandler(tView_Paint);
/*
also tried:
this.Paint += ...
base.Paint += ...
*/
}

private void tView_Paint(object sender,
System.Windows.Forms.PaintEventArgs e)
{
/*
the following line has a break on it,
but the program never breaks.. so this
isn't running?
*/
Debug.WriteLine("blah");
}
#endregion
Nov 16 '05 #1
1 4121
nevermind... Turns out that windows handles the drawing of this control
- so in order to change how it's drawn, you have to draw it yourself by
setting userpaint to true in the constructor, and then using OnPaint and
draw everything yourself:

in constructor:
SetStyle(ControlStyles.UserPaint, true);

then use this:
protected override void OnPaint(PaintEventArgs pe)
{
/*
place all of your custom paint code here... note, you have to draw
everything yourself!
*/
}
Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: (Pete Cresswell) | last post by:
I've got KeyDown coding and it fires when other keys are pressed, but when Enter is pressed, nothing. I'd like to support the (standard?) Windows behavior of executing DblClick processing when...
4
by: Tamir Khason | last post by:
Why when I lost focus (go to back) on form all GDI+ paints disappears..... BUG or I do something wrong???? TNX
8
by: JJBean | last post by:
Hi All, How do I create a custom paint treeview control or an owner drawn treeview control ? Any tutorials on this anywhere? Thanks, JJBean
3
by: jrhoads23 | last post by:
I have been wondering this for some time. If I create my own class inherited from an existing class or create a user control, should I be overriding the OnFontChanged method (or similar) or...
6
by: jcrouse | last post by:
I am rotating some text is some label controls. In the one place I use it it works fine. In the other place I use it I can't figure out the syntax. I don't really understand the event. Where it...
7
by: hamil | last post by:
The following code will display a tif file on a form. When another form is moved over the tif image, the tif image is erased where the form was moved. A paint event occurs when this happens. My...
7
by: Rotsey | last post by:
Hi, I have a interface that I use for a form so I can pass the form to another object. How do I add the Paint event to the interface and subsequently handle the paint event in my other...
5
by: =?Utf-8?B?SmVzcGVyLCBEZW5tYXJr?= | last post by:
Hi, On a usercontrol I've put a set of radiobuttons within a groupbox. These radiobuttons have visual style enables, i.e. they turn orange when hovering over them and green when pushed. ...
6
by: Tom P. | last post by:
I'm trying to make one of our perennial favorites - The Syntax Color Editor. (Mostly as a learning exercise). I'm wondering if there is a way to capture the Paint event of a textbox so I can...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.