HI All,
I have one form consisting of 32 fields in which most of them are mandatory.After
clicking on save button i am adding the field's related name to Collections(List of string) and displaying message box with the names.I want the focus to move to the first control displaying in message box.
I am doing something like this
In button Click
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
Try
IsValidData()
If m_InvalidList.Count > 0 Then
Dim sFields As String = ""
For iCnt As Int32 = 0 To m_InvalidList.Count - 1
sFields &= m_InvalidList(iCnt).ToString & vbCrLf
Next
XtraMessageBox.Show(" Please Fill The Following Fields : " & vbCrLf & "--------------------------------------" & vbCrLf & sFields, "Field Validator", MessageBoxButtons.OK)
Else
SaveGenLedgerMaster()
End If
Catch ex As Exception
ErrorLog(ex)
End Try
End Sub
Private Sub IsValidData()
Try
m_InvalidList.Clear()
If xtbGLName.Text = "" Then m_InvalidList.Add("General Ledger Name")
If cmbGLSchedule.Text = "" Then m_InvalidList.Add("Schedule name")
If ccbCompany.Text = "" Then m_InvalidList.Add("Company")
If ccbSegment.Text = "" Then m_InvalidList.Add("Segment")
Catch ex As Exception
ErrorLog(ex)
End Try
End Sub
I want to focus the control binded to the first string in the List .How can i do this..is there any way other than this..like adding control to the list instead and set focus...please help me out..