473,322 Members | 1,540 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,322 software developers and data experts.

An embarrassingly single question

Hi, still learning VB.Net and have this very simple question.
Why does my console debug window never display "TestOnPaint" ?
Chris

Public Class Form1
Inherits System.Windows.Forms.Form

'[+] Windows Form Designer generated code

Private Class SCListBox
Inherits ListBox

Protected Overrides Sub OnPaint(ByVal e As _
System.Windows.Forms.PaintEventArgs)
Debug.WriteLine("TestOnPaint")
MyBase.OnPaint(e)
End Sub

End Class
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim f As New SCListBox
f.Text = "ff"
Me.Controls.Add(f)
f.Visible = True
f.Refresh()
End Sub

End Class
Nov 20 '05 #1
4 1080
"Christian O'Connell" <cd********@hotmail.com> schrieb
Hi, still learning VB.Net and have this very simple question.
Why does my console debug window never display "TestOnPaint" ?
Chris

Public Class Form1
Inherits System.Windows.Forms.Form

'[+] Windows Form Designer generated code

Private Class SCListBox
Inherits ListBox

Protected Overrides Sub OnPaint(ByVal e As _
System.Windows.Forms.PaintEventArgs)
Debug.WriteLine("TestOnPaint")
MyBase.OnPaint(e)
End Sub

End Class
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim f As New SCListBox
f.Text = "ff"
Me.Controls.Add(f)
f.Visible = True
f.Refresh()
End Sub

End Class


Probably OnPaint is not called with listboxes because a listbox is a
"native" Windows control painted by Windows itself.

http://msdn.microsoft.com/library/en.../listboxes.asp

--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #2
Hi,

Try this.

Private Class SCListBox

Inherits ListBox

Protected Overrides Sub OnPaint(ByVal e As _

System.Windows.Forms.PaintEventArgs)

Debug.WriteLine("TestOnPaint")

MyBase.OnPaint(e)

End Sub

Public Sub New()

Me.SetStyle(ControlStyles.UserPaint, True)

End Sub

End Class

Ken

----------------------------

"Christian O'Connell" <cd********@hotmail.com> wrote in message
news:9a**************************@posting.google.c om...
Hi, still learning VB.Net and have this very simple question.
Why does my console debug window never display "TestOnPaint" ?
Chris

Public Class Form1
Inherits System.Windows.Forms.Form

'[+] Windows Form Designer generated code

Private Class SCListBox
Inherits ListBox

Protected Overrides Sub OnPaint(ByVal e As _
System.Windows.Forms.PaintEventArgs)
Debug.WriteLine("TestOnPaint")
MyBase.OnPaint(e)
End Sub

End Class
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim f As New SCListBox
f.Text = "ff"
Me.Controls.Add(f)
f.Visible = True
f.Refresh()
End Sub

End Class

Nov 20 '05 #3
* cd********@hotmail.com (Christian O'Connell) scripsit:
Hi, still learning VB.Net and have this very simple question.
Why does my console debug window never display "TestOnPaint" ?


This doesn't work with the listbox. You may want to set its style to
ownerdrawn and draw the items in the control's 'DrawItem' event handler.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #4
Thanks everyone. It is making sense now.
Chris.

cd********@hotmail.com (Christian O'Connell) wrote in message news:<9a**************************@posting.google. com>...
Hi, still learning VB.Net and have this very simple question.
Why does my console debug window never display "TestOnPaint" ?
Chris

Public Class Form1
Inherits System.Windows.Forms.Form

'[+] Windows Form Designer generated code

Private Class SCListBox
Inherits ListBox

Protected Overrides Sub OnPaint(ByVal e As _
System.Windows.Forms.PaintEventArgs)
Debug.WriteLine("TestOnPaint")
MyBase.OnPaint(e)
End Sub

End Class
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim f As New SCListBox
f.Text = "ff"
Me.Controls.Add(f)
f.Visible = True
f.Refresh()
End Sub

End Class

Nov 20 '05 #5

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

Similar topics

5
by: sinister | last post by:
The examples in the online manual all seem to use double quotes, e.g. at http://us3.php.net/preg_replace Why? (The behavior is different with single quotes, and presumably simpler to...
6
by: yvinogradov | last post by:
I have a qustion about the attached piece of code. It compiles on gcc version 3.4.1 (Cygwin special). The line in question has a single colon instead of double. With double colon everything works...
0
by: gene | last post by:
Raw DMS single- vs. multi-table tablespaces I am looking for info re recommendations and performance comparisons of single vs. multiple table allocations in raw DMS tablespaces. While it seems...
19
by: Geetesh | last post by:
Recently i saw a code in which there was a structer defination similar as bellow: struct foo { int dummy1; int dummy2; int last }; In application the above array is always allocated at...
28
by: rajendra.stalekar | last post by:
Hi Folks!!! I have a string let's say "hi" and got to reverse it using just a single variable for swapping, how do I do it? Regards, Rajendra S.
3
by: R Millman | last post by:
under ASP.NET, single stepping in debug mode appears not to stop within event procedures. i.e. 1) Create web page with submit button and event procedure for the click event in the code behind...
3
by: Claudio Pacciarini | last post by:
Hi everyone, I have a question about .NET code sharing and reuse, and also about application design best practices / guidelines. Currently, we have many different .NET projects in source...
35
by: keerthyragavendran | last post by:
hi i'm downloading a single file using multiple threads... how can i specify a particular range of bytes alone from a single large file... for example say if i need only bytes ranging from...
3
by: sklett | last post by:
I suspect the answer might be in one of the words of my subject, but here goes anyway. I'm working on a system that will execute a very long (300+) chain of task objects. Here is some quick...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.