Hi,Im converting VB6 code to VB.net..i got following code from converter
In vb6 myForm.show vbModal method is triggering Got_Focus event.

But in the foll code,showDialog() method is triggering Load event.I need Enter evwent to be triggered which is equivalent to Got_Focus.

Is it possible to do so??

pls help me.

Thanks & Regards
Rahul

MyForm = New frmNonProportionalDialog
'Load(MyForm)
MyForm.Show()
MyForm.Visible = False
MyForm.Text = Caption
MyForm.txtMsg(0).Text = Temp
If Not MonoFont Then
MyForm.txtMsg(0).Font = VB6.FontChangeName(MyForm.txtMsg(0).Font, MyForm.Font.Name)
MyForm.txtMsg(0).Font = VB6.FontChangeBold(MyForm.txtMsg(0).Font, MyForm.Font.Bold)
MyForm.txtMsg(0).Font = VB6.FontChangeSize(MyForm.txtMsg(0).Font, MyForm.Font.SizeInPoints)
MyForm.txtMsg(1).Font = VB6.FontChangeName(MyForm.txtMsg(1).Font, MyForm.Font.Name)
MyForm.txtMsg(1).Font = VB6.FontChangeBold(MyForm.txtMsg(1).Font, MyForm.Font.Bold)
MyForm.txtMsg(1).Font = VB6.FontChangeSize(MyForm.txtMsg(1).Font, MyForm.Font.SizeInPoints)
MyForm.Tag = "PROP"
End If
If IconCode <> 0 Then
i = (IconCode / 16) - 1
If i >= 0 And i <= 5 Then MyForm.imgIcon(0).Tag = Trim(Str(i))
End If
TrackerMsgBoxButton = ""
MyForm.cmdOK(0).Tag = ButtonNames
MyForm.PerformClickHandled()
System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default
MyForm.ShowDialog()

-------------------------------------------------
the Enter event is shown below.
I cannot use load or shown event becoz it is associted with txt_msg and not the frmNonProportionalDialog

Private Sub txtMsg_Enter(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtMsg.Enter
Dim Index As Short = txtMsg.GetIndex(eventSender)
If Index = 0 Then
If txtMsg(0).Tag <> "ALLOW FOCUS" Then
Call ControlSetFocus(cmdOK(0))
End If
End If
End Sub

Is there is any solution??

You can call the Sub Form_Enter from your Sub Form_Load; just pass the sender and e you got from the function call.

Form_Enter(sender, e)

There is a GotFocus event for forms. in your code window click the line that says events for your main form in the droplist at the top. Gotfocus should then be in the events droplist on the right.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.