473,407 Members | 2,326 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,407 software developers and data experts.

Owner Draw Radio Button

Trying to place a few radio buttons where I draw the image on the button. I declare an array of three buttons and initialize them as below. The paint event is getting triggered for the buttons, but my drawing never shows up. What am I doing wrong? Thanks.
For x As Integer = 0 To 2
drawStyle(x) = New RadioButton
With drawStyle(x)
.Width = pnlPalette.Width - 4
.Height = 24
.Appearance = Appearance.Button
.FlatStyle = FlatStyle.Popup
.Left = 2
.Tag = x
End With
pnlPalette.Controls.Add(drawStyle(x))
AddHandler drawStyle(x).Paint, AddressOf drawStyle_Paint
Next

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

Private Sub drawStyle_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs)
Dim r As RadioButton = sender
Dim g As Graphics = r.CreateGraphics()

With r
If (.Tag = "One") Then g.FillRectangle(New SolidBrush(_fillColor), 2, 2, .Width - 4, .Height - 4)
If (.Tag = "Two") Then g.DrawRectangle(New Pen(_lineColor, _lineWidth), 2, 2, .Width - 4, .Height - 4)
End With
End Sub
Nov 21 '05 #1
2 2743
"Rlrcstr" <rl*****@msn.com> schrieb:
Trying to place a few radio buttons where I draw the image on the button.
I declare an array of three buttons and initialize them as below. The
paint event is getting triggered for the buttons, but my drawing never
shows up. What am I doing wrong? Thanks.

For x As Integer = 0 To 2
drawStyle(x) = New RadioButton
With drawStyle(x)
.Width = pnlPalette.Width - 4
.Height = 24
.Appearance = Appearance.Button
.FlatStyle = FlatStyle.Popup
.Left = 2
.Tag = x
End With
pnlPalette.Controls.Add(drawStyle(x))
AddHandler drawStyle(x).Paint, AddressOf drawStyle_Paint
Next<<<

Instead of adding a handler to the buttons' 'Paint' events, create a class
that inherits from 'RadioButton' and overrides its 'OnPaint' method. Place
your drawing code in the 'OnPaint' method and use the derived class instead
of the standard radio button control.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #2
Perfect. Thanks.
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:et*************@tk2msftngp13.phx.gbl...
"Rlrcstr" <rl*****@msn.com> schrieb:
Trying to place a few radio buttons where I draw the image on the button.I declare an array of three buttons and initialize them as below. The
paint event is getting triggered for the buttons, but my drawing never
shows up. What am I doing wrong? Thanks.


For x As Integer = 0 To 2
drawStyle(x) = New RadioButton
With drawStyle(x)
.Width = pnlPalette.Width - 4
.Height = 24
.Appearance = Appearance.Button
.FlatStyle = FlatStyle.Popup
.Left = 2
.Tag = x
End With
pnlPalette.Controls.Add(drawStyle(x))
AddHandler drawStyle(x).Paint, AddressOf drawStyle_Paint
Next<<<

Instead of adding a handler to the buttons' 'Paint' events, create a class
that inherits from 'RadioButton' and overrides its 'OnPaint' method.

Place your drawing code in the 'OnPaint' method and use the derived class instead of the standard radio button control.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #3

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

Similar topics

4
by: Oscar Monteiro | last post by:
I Have to sets of Radio buttons like so: <input type="radio" name=p1 value=1> <input type="radio" name=p1 value=2> <input type="radio" name=p1 value=3> <br> <input type="radio" name=p2 value=1>...
5
by: Digital Puer | last post by:
I have the following HTML form: - radio button A (default selected) - radio button B - input field, of type "file" with "Choose" button - submit button I would like to have it so that if the...
12
by: Jim H | last post by:
I have a ListBox hold a list of my custom controls (it's UserControl based control with a couple radio buttons and a checkbox). Everything works and displays the way I expected it to. I can move...
0
by: John R. | last post by:
I want to add a textbox next to each item in a Listbox on a Windows Form. The items need to be scrollable so I thought that maybe this is possible with an Owner Draw listbox. Searching the web...
2
by: dan heskett | last post by:
I am owner-drawing a listbox, in an attempt to create a nice list with some custom "fields" and text layout. Essentially it works, but I must be missing something big, conceptually, because I...
0
by: Brian Henry | last post by:
I cant seem to remember this one... I have a list view, and im owner drawing the items, i dont want the selection to hide when it loses focus so i have hideselection = false, but when i owner draw...
9
by: IchBin | last post by:
I can not see what the problem is with this script. I am just trying to set a radio button by calling setCheckedValue('abbr_letter', 'V'). Sorry I am new to javascript. <html> <head> <script...
10
by: IchBin | last post by:
I am trying to set the state of a radio button. I do not see what I am doing wrong. Sorry, I am new at this.. I need another set of eyes to look at this snip of code. I am trying to set the radio...
8
by: photoboy | last post by:
I have racked by brain long enough on this, so now I need the help of someone who knows what they are doing. Here is what I am trying to achieve: First, I have two radio buttons (both unchecked)...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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.