I've modified the standard text box to change the background color on
the "Enter" event and to change the color back to the original value
on "Leave". I've also added a bunch of other methods and properties,
but I don't think that any of them are the issue.
I want to select all of the text when the user clicks on the control.
I have an option to have a borderless box for display, but force a
border during edit. I have to move the box and resize the parameters
to allow for the four pixel dimension change of the border and to keep
the data aligned correctly on the screen. If I use this option, the
SelectAll() command works correctly.
If I use the defaults of having a border in display mode as well as
edit mode, the SelectAll command does not work.
Me.BorderStyle = BorderStyle.Fixed3D
m_EditForceBorder = 0
I've played with moving the Me.Invalidate and a couple of Mickey Mouse
kludges, but not having any luck.
Does anybody have a clue?
Thanks
Shane
Code fragments below.
Imports System.ComponentModel
Imports System.Text
.. . .
<ToolboxBitmap(GetType(SssiTextBox))> _
Public Class SssiTextBox
Inherits TextBox
.. . .
Private Sub SssiTextBox_Enter(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Enter
m_EnterValue = Me.Text ' Save entry value
Me.BackColor = m_EnterFocusBackColor
Me.ForeColor = m_EnterFocusForeColor
If m_EditForceBorder <> 0 And Me.BorderStyle =
BorderStyle.None Then
m_EditPreviousBorder = Me.BorderStyle ' Save current
border
Me.BorderStyle = m_EditForceBorder
Me.Height += 4
Me.Width += 4
Me.Top -= 4
Me.Invalidate()
End If
Me.SelectAll()
End Sub
.. . .
'---------- Reset colors on leave, unless Mandatory and empty
----------
Private Sub SssiTextBox_Leave(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Leave
If Trim(Me.Text).Length = 0 And m_IsMandatory Then
Me.BackColor = m_MandatoryBackColor
Me.ForeColor = m_MandatoryForeColor
Else
Me.BackColor = m_LeaveFocusBackColor
Me.ForeColor = m_LeaveFocusForeColor
End If
If m_EditForceBorder <> 0 And Me.BorderStyle <>
m_EditPreviousBorder Then
Me.BorderStyle = m_EditPreviousBorder
Me.Height -= 4
Me.Width -= 4
Me.Top += 4
Me.Invalidate()
End If
If m_EnterValue <> Me.Text Then RaiseEvent
ValueChanged(sender, e)
End Sub