Redisplaying a Dialog box and positioning the Cursor

OHK79

New member
Joined
Apr 16, 2009
Messages
1
Programming Experience
Beginner
Hi

I am very new to VB (and this forum) so I hope I am putting this in the correct place.


After checking a value in a text box I am having trouble re-dispalying the dialog box and setting the cursor to the empty field. Can anyone help.

Many thanks

Public Class frmCategory

Private Sub cmdOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdOK.Click
If Me.txtCategory.Text = "" Then
MsgBox("Field Can not be Blank : " & Label1.Text)

RELOAD THE DIALOG and SET THE CURSOR To the EMPTY TEXT BOX

End If
'Me.Hide()

End Sub
 
I guess your cmdOK button has DialogResult set in Designer, which means after Click code in done the dialog returns. If you need to conditionally set the DialogResult remove the Designer value from the button and instead set the value from the Click handler when it is appropriate to return the dialog. Then you would set code like this:
VB.NET:
Me.DialogResult = DialogResult.OK
 
Back
Top