Question Raise event from sub class

baburc

New member
Joined
Aug 29, 2009
Messages
1
Programming Experience
5-10
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()
InitializeComponent()
Me.LstBox = New System.Windows.Forms.ListBox
Me.Controls.Add(Me.LstBox)

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
MsgBox("ggg")
End Sub

Here the event is not raising.

Thanks.
 

henryminute

Well-known member
Joined
Jul 24, 2009
Messages
57
Location
UK
Programming Experience
10+
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