I apologize in advance as I'm still new to programming in VB. I am trying to create a custom DataGridView control that has filtering textboxes/comboboxes and an image in the header cells. I've created a CustomHeaderCell class and have been able to add the image by overriding the Paint event, but I cannot seem to add any controls. I've seen a couple examples in C#, but I haven't had any luck translating it to VB.NET.
I think I'm supposed to add the textbox/combobox and eventhandlers in the Paint Event as well, but all I have been able to do is draw images & rectangles. I'm using Visual Studio 2015. Any help would be greatly appreciated!!
What I have tried:
Public Class CustomGridHeaderCell
Inherits DataGridViewColumnHeaderCell
Public Textbox As New TextBox
Protected Overrides Sub Paint(graphics As Graphics, clipBounds As Rectangle, cellBounds As Rectangle, rowIndex As Integer, dataGridViewElementState As DataGridViewElementStates, value As Object, formattedValue As Object, errorText As String, cellStyle As DataGridViewCellStyle, advancedBorderStyle As DataGridViewAdvancedBorderStyle, paintParts As DataGridViewPaintParts)
MyBase.Paint(graphics, clipBounds, cellBounds, rowIndex, dataGridViewElementState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts)
Dim Textbox As New TextBox
Textbox.Name = "Textbox"
Textbox.Location = New Point(100, 0)
Textbox.Height = (cellBounds.Height - 2) / 2
Textbox.Width = cellBounds.Width - 2
Textbox.BackColor = Color.Red
Textbox.CreateControl()
End Sub
End Class