Creating a flat combobox within vb.net ?

T

Tim

Dear All,

I have spend a number of hours attempting to find some answers about
how to remove the 3D BorderStyle within a combobox and have come to
the conclusion that the simplest method is to create a user control
and hide the borders using some panels.

This however is not the most efficient method of doing things so I
appeal to those developers who know far more than I. I assume you need
to create a derived class which inherits the combobox control as so;
-------------------------------------------
Public Class MyCombo
Inherits System.Windows.Forms.ComboBox

Public Sub New()
MyBase.New()
End Sub

End class
-----------------------------------------------
This gives me the basic combobox that I can then include within my
form;

---------------------------------------------
Public Class Form1
Inherits System.Windows.Forms.Form

Protected oMyCombo As MyCombo


#Region " Windows Form Designer generated code "

|
|
|


Private Sub InitializeComponent()
Me.oMyCombo = New WindowsApplication1.MyCombo()

'oMyCombo
'
Me.oMyCombo.Location = New System.Drawing.Point(44, 32)
Me.oMyCombo.Name = "oMyCombo"
Me.oMyCombo.Size = New System.Drawing.Size(131, 21)
Me.oMyCombo.TabIndex = 0
'

Me.Controls.Add(Me.oMyCombo)
end sub
#end region
----------------------------------------------------

I'm need to now get into and look at the code for the OnPaint event
for the class MyCombo, however I just can't seem to even get this to
fire let alone look at the underling code that is used to draw the
control ?

I was using the following within the MyCombo class;

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

Protected Overridable Overloads Sub onPaint(ByVal sender As Object,
ByVal e As System.Windows.Forms.PaintEventArgs)

Try
Debug.Write(e.Graphics.ClipBounds.ToString)

MyBase.onPaint(e)
'e.Graphics.
MsgBox("paint fired")

Catch ex As Exception
' empty catch
Finally

End Try

End Sub
-----------------------------

Any help would be greatly appreciated.

Kind Regards,

Tim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top