lburnsinmagnolia
asked on
Rasing events vb.net
Converting a project from C# to VB.NET and having trouble coding the event handler.
Here is sample from C# and VB.NET Need to know how to enable the event handler in VB
public class RowControl
{
public delegate void AddNewRowEventHandler(obje ct sender, EventArgs e);
public event AddNewRowEventHandler AddNewRowEvent;
...
on form: collectionslist
private void AddNewRow(int rowIDX)
{
RowControl control = new RowControl(ramCustomersDic t, rowControlsList, rowIDX); //row 0 is column headers
control.stopLabel.Text = rowIDX.ToString();
rowControlsList.Add(contro l);
tableLayoutPanel1.Add(cont rol);
control.AddNewRowEvent += new RowControl.AddNewRowEventH andler(thi s.AddNewRo wEvent);
}
//************************ ********** ********** ********** ********** ********** *
private void AddNewRowEvent(object sender, EventArgs e)
{
RowControl rc = rowControlsList.Last();
if (rc.customerIdTextBox.Text .Length > 0 && rc.addressTextbox.Text.Len gth > 0)
{
int rowIDX = rowControlsList.Count + 1;
AddNewRow(rowIDX);
}
}
Now in VB, I have this:
Public Class RowControl
Public Delegate Sub AddNewRowEventHandler(send er As Object, e As EventArgs)
Public Event AddNewRowEvent As AddNewRowEventHandler
...
on the form:
Private Sub AddNewRow(rowIDX As Integer)
dim control as New RowControl(ramCustomersDic t, rowControlsList, rowIDX)
'row 0 is column headers
control.stopLabel.Text = rowIDX.ToString()
rowControlsList.Add(contro l)
TableLayoutPanel1.Add(cont rol)
control.AddNewRowEvent() += New RowControl.AddNewRowEventH andler(Add ressOf Me.AddNewRowEvent)
End Sub
'************************* ********** ********** ********** ********** **********
Private Sub AddNewRowEvent(sender As Object, e As EventArgs)
Dim rc As RowControl = rowControlsList.Last
If rc.customerIdTextBox.Text. Length > 0 AndAlso rc.addressTextbox.Text.Len gth > 0 Then
Dim rowIDX As Integer = rowControlsList.Count + 1
AddNewRow(rowIDX)
End If
End Sub
SO my question is....How do I get my event raised?
I am getting the error saying i Need to call raiseevent, but when I try to enter the code for raiseevent, nothing appears.
Thanks
Here is sample from C# and VB.NET Need to know how to enable the event handler in VB
public class RowControl
{
public delegate void AddNewRowEventHandler(obje
public event AddNewRowEventHandler AddNewRowEvent;
...
on form: collectionslist
private void AddNewRow(int rowIDX)
{
RowControl control = new RowControl(ramCustomersDic
control.stopLabel.Text = rowIDX.ToString();
rowControlsList.Add(contro
tableLayoutPanel1.Add(cont
control.AddNewRowEvent += new RowControl.AddNewRowEventH
}
//************************
private void AddNewRowEvent(object sender, EventArgs e)
{
RowControl rc = rowControlsList.Last();
if (rc.customerIdTextBox.Text
{
int rowIDX = rowControlsList.Count + 1;
AddNewRow(rowIDX);
}
}
Now in VB, I have this:
Public Class RowControl
Public Delegate Sub AddNewRowEventHandler(send
Public Event AddNewRowEvent As AddNewRowEventHandler
...
on the form:
Private Sub AddNewRow(rowIDX As Integer)
dim control as New RowControl(ramCustomersDic
'row 0 is column headers
control.stopLabel.Text = rowIDX.ToString()
rowControlsList.Add(contro
TableLayoutPanel1.Add(cont
control.AddNewRowEvent() += New RowControl.AddNewRowEventH
End Sub
'*************************
Private Sub AddNewRowEvent(sender As Object, e As EventArgs)
Dim rc As RowControl = rowControlsList.Last
If rc.customerIdTextBox.Text.
Dim rowIDX As Integer = rowControlsList.Count + 1
AddNewRow(rowIDX)
End If
End Sub
SO my question is....How do I get my event raised?
I am getting the error saying i Need to call raiseevent, but when I try to enter the code for raiseevent, nothing appears.
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
RowControl.vb -
Open in new window
Form methods -
Open in new window
-saige-