Question Raise event from sub class


New member
Aug 29, 2009
Programming Experience
I have 2 classes one main class called Mygrid and another class inside it called TLBoxEditingControl which inherits a textbox into grid cell.

Also I have added one Listbox called LstBox to the usercontrol MyGrid.

1) Initially its visible is false. How can i make visible true in TLBoxEditingControl class.

2) I have an Event called MyList() in Main Class, how can I raise this event in TLBoxEditingControl class.

Here is the code i use, This is not working please expalin

Public Class MyGrid
Inherits DataGridView

Public Event MyList()

Public Sub New()
Me.LstBox = New System.Windows.Forms.ListBox

LstBox.Top = 20
LstBox.Left = 20
LstBox.Visible = False
End Sub

Private Sub LstList()
RaiseEvent MyList()
End Sub

End Class

Private Class TLBoxEditingControl
Inherits TextBox
Implements IDataGridViewEditingControl
Private DataGridViewControl As DataGridView
Private ValueIsChanged As Boolean = False
Private RowIndexNum As Integer

Dim Myg As New MyGrid()

Private Sub TlBoxEditingControl_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.TextChanged
Call Myg.LstList() ' Here I want to raise Mylist Event
Myg.LstBox.Visible = True ' Here i want to make LstBox visible
End Sub

End Class

I have added this control to a form and added this code

Private Sub MyGrid1_MyList() Handles MyGrid1.MyList
End Sub

Here the event is not raising.



Well-known member
Jul 24, 2009
Programming Experience
AFAIK you cannot use the DataGridView control in the way that you are trying to do.

The Cells of a DataGridView are, by default, DataGridViewTextBoxCells so your efforts to add a TextBox are unnecessary, in addition to being incorrect.

I am not aware of any way to add a ListBox to a DataGridview Control. You can have multi-line TextBoxes, so if that is the effect that you are trying to achieve please post back and I will try to assist you.

Without knowing what it is that you are trying to do it is very difficult to advise you properly.

Top Bottom