I've been having trouble converting the following fairly straight forward c# code into vb.net 4.0, which I understand has anonymous delegates. I just havn't been able to figure it out yet.
_combo.DataBound += (sender, args) =>
{
var item = _combo.FindItemByValue(values[0].ToString());
if (item != null)
item.Selected = true;
};
I have tried the following
_combo.DataBound += Function(sender, args)
Dim item = _combo.FindItemByValue(values(0).ToString())
If item IsNot Nothing Then
item.Selected = True
End If
End Function
But the compiler complains that DataBound can not be called directly, but has to be called with RaiseEvents
AddHandler _combo.DataBound, Function(sender, args)... End Function is I think proper syntax.