Click here to Skip to main content
15,914,488 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionString Manipulation Pin
Chibuye14-Oct-07 1:51
Chibuye14-Oct-07 1:51 
AnswerRe: String Manipulation Pin
Hesham Amin14-Oct-07 4:49
Hesham Amin14-Oct-07 4:49 
GeneralRe: String Manipulation Pin
Chibuye14-Oct-07 21:15
Chibuye14-Oct-07 21:15 
Questionmulticolumn combobox in vb.net2005 Pin
nilam1114-Oct-07 1:19
nilam1114-Oct-07 1:19 
Questiondatatablemapping vb.net2005 Pin
nilam1114-Oct-07 1:02
nilam1114-Oct-07 1:02 
QuestionSQL Select Command in VB.net Pin
Abbhie13-Oct-07 22:56
Abbhie13-Oct-07 22:56 
AnswerRe: SQL Select Command in VB.net Pin
Christian Graus13-Oct-07 23:11
protectorChristian Graus13-Oct-07 23:11 
Questionerror provider Pin
Mark Cabbage13-Oct-07 20:40
Mark Cabbage13-Oct-07 20:40 
Hi everyone.
Hoping for some clarification how the error provider and the "validating" event works on a form, because what I am experiencing doesn't seem very user friendly for the end user.

In a nutshell, once the control FAILS my conditions in the "validating" event and I issue the e.cancel command, focus returns to the failed control and I cannot move the focus until the control has a valid entry.

Why is this bad ? For example, consider a textbox that accepts a file system directory path, and a browse button next to it. I want the advanced users to be able to type (using autocomplete) the path and basic users to be able to use the browse button. However once the textbox has the focus, any attempts to click on the browse button fail as the focus cannot move from the textbox that just failed validation.

Now I have read a lot of articles, and it appears the error provider doesn't normally exhibit this behaviour. Am I right ?? If it is not normal, any ideas what might cause this ??

- I have a form with a tabcontrol that has several pages
- I have an error provider on the form
- All bound controls reference the same bindingsource
- initially the error provider had a datasource of the bindingsource. I removed it and still nothing.


Here is one of the pieces of code:


Private Sub txtClientBaseFilePath_Validating(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txtClientBaseFilePath.Validating

Dim IsError As Boolean = False

'check if the string is not null using the basic textbox validation
If IsTextBoxEmpty(txtClientBaseFilePath, strErrorPathNotSpecified & strErrorPath) = True Then
IsError = True
Else

'check if the patch exists. if not exist then offer to create the path
Try

If My.Computer.FileSystem.DirectoryExists(txtClientBaseFilePath.Text) = False Then
If MessageBox.Show("Directory does not exist. " & vbCrLf & vbCrLf & "Would you like to create the directory?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) = Windows.Forms.DialogResult.Yes Then
My.Computer.FileSystem.CreateDirectory(txtClientBaseFilePath.Text)
SetStatusLabel("Directory '" & txtClientBaseFilePath.Text & "' created successfully", False)
Else
Me.epSystemSettings.SetError(txtClientBaseFilePath, strErrorPathMustExist)
IsError = True
End If
Else
'directory exists OK
End If


'catch errors such as creating path fails due to rights, invalid path, etc
Catch ex As ArgumentException
'The directory name is malformed. For example, it contains illegal characters or is only white space (ArgumentException Class).
'The directory name is Nothing (ArgumentNullException Class).
Me.epSystemSettings.SetError(txtClientBaseFilePath, strErrorPathInvalidCharacters & strErrorPath)
SetStatusLabel("Directory creation failed - " & strErrorPathInvalidCharacters, True)
IsError = True


Catch ex As IO.PathTooLongException
'The directory name is too long (PathTooLongException Class).
Me.epSystemSettings.SetError(txtClientBaseFilePath, strErrorPathTooLong & strErrorPath)
SetStatusLabel("Directory creation failed - " & strErrorPathTooLong, True)
IsError = True


Catch ex As IO.IOException
'The parent directory of the directory to be created is read-only (IOException Class).
Me.epSystemSettings.SetError(txtClientBaseFilePath, strErrorPathReadOnly & strErrorPath)
SetStatusLabel("Directory creation failed - " & strErrorPathReadOnly, True)
IsError = True


Catch ex As NotSupportedException
'The directory name is only a colon (Smile | :) . (NotSupportedException Class).
Me.epSystemSettings.SetError(txtClientBaseFilePath, strErrorPathNotSupported & strErrorPath)
SetStatusLabel("Directory creation failed - " & strErrorPathNotSupported, True)
IsError = True


Catch ex As UnauthorizedAccessException
'The user does not have permission to create the directory (UnauthorizedAccessException).
Me.epSystemSettings.SetError(txtClientBaseFilePath, strErrorPathNoRights & strErrorPath)
SetStatusLabel("Directory creation failed - " & strErrorPathNoRights, True)
IsError = True


Catch ex As Security.SecurityException
'A partial-trust situation exists in which the user does not have sufficient permissions (SecurityException).
Me.epSystemSettings.SetError(txtClientBaseFilePath, strErrorPathNoRights & strErrorPath)
SetStatusLabel("Directory creation failed - " & strErrorPathNoRights, True)
IsError = True


Catch ex As Exception
Throw ex
IsError = True

End Try

End If

If Not IsError Then
Me.epSystemSettings.SetError(txtClientBaseFilePath, "")
End If

e.Cancel = IsError


End Sub


AnswerRe: error provider Pin
Mark Cabbage13-Oct-07 21:59
Mark Cabbage13-Oct-07 21:59 
QuestionHow to make a window Flash Pin
WestSideRailways13-Oct-07 13:22
WestSideRailways13-Oct-07 13:22 
AnswerRe: How to make a window Flash Pin
Christian Graus13-Oct-07 14:22
protectorChristian Graus13-Oct-07 14:22 
GeneralRe: How to make a window Flash Pin
WestSideRailways13-Oct-07 15:20
WestSideRailways13-Oct-07 15:20 
GeneralRe: How to make a window Flash Pin
Christian Graus13-Oct-07 16:22
protectorChristian Graus13-Oct-07 16:22 
GeneralRe: How to make a window Flash Pin
WestSideRailways13-Oct-07 18:29
WestSideRailways13-Oct-07 18:29 
GeneralRe: How to make a window Flash Pin
Christian Graus13-Oct-07 20:44
protectorChristian Graus13-Oct-07 20:44 
GeneralRe: How to make a window Flash Pin
The ANZAC14-Oct-07 15:03
The ANZAC14-Oct-07 15:03 
Questionprinting RTB contents Pin
BooleanTrue13-Oct-07 11:50
professionalBooleanTrue13-Oct-07 11:50 
AnswerRe: printing RTB contents Pin
Dave Kreskowiak13-Oct-07 15:23
mveDave Kreskowiak13-Oct-07 15:23 
AnswerRe: printing RTB contents Pin
Duncan Edwards Jones14-Oct-07 0:44
professionalDuncan Edwards Jones14-Oct-07 0:44 
QuestionEditing Text Files and Creating new one of them Pin
Kalpeshpatelbyk13-Oct-07 2:07
Kalpeshpatelbyk13-Oct-07 2:07 
AnswerRe: Editing Text Files and Creating new one of them Pin
pmarfleet13-Oct-07 4:40
pmarfleet13-Oct-07 4:40 
AnswerRe: Editing Text Files and Creating new one of them Pin
Christian Graus13-Oct-07 10:29
protectorChristian Graus13-Oct-07 10:29 
QuestionTargetInvocationException, FileNotFoundException, assemblys, remoting, services, depression. Pin
redjen13-Oct-07 2:02
redjen13-Oct-07 2:02 
AnswerRe: TargetInvocationException, FileNotFoundException, assemblys, remoting, services, depression. Pin
redjen13-Oct-07 2:03
redjen13-Oct-07 2:03 
GeneralRe: TargetInvocationException, FileNotFoundException, assemblys, remoting, services, depression. Pin
redjen13-Oct-07 14:29
redjen13-Oct-07 14:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.