A
aaapaul
I have a derived combobox with locking property. The user can see,
what items are in the combobox but he can' t change them.
This is my code:
Imports System.Windows.Forms
Imports System.ComponentModel
Public Class LCombo
Inherits ComboBox
Private m_blnLocked As Boolean
Private m_oldIndex As Integer
Public Property Locked() As Boolean
Get
Return Me.m_blnLocked
End Get
Set(ByVal value As Boolean)
m_blnlocked = value
End Set
End Property
Public Overrides Property SelectedIndex() As Integer
Get
Return MyBase.SelectedIndex
End Get
Set(ByVal Value As Integer)
m_oldIndex = Value
MyBase.SelectedIndex = Value 'Line XYZ
End Set
End Property
Sub New()
MyBase.New()
End Sub
Private Sub LCombo_SelectedIndexChanged(ByVal sender As Object,
ByVal e As System.EventArgs) Handles Me.SelectedIndexChanged
If Me.m_blnLocked Then
Me.SelectedIndex = m_oldIndex
End If
End Sub
Starting my program, I get an error at Line XYZ (see above).
"InvalidArgument=Value with Value 0 is for SelectedIndex invalid
Parametername: SelectedIndex
Do you have any idea? Is this possible at all?
Thanks
aaaPaul
what items are in the combobox but he can' t change them.
This is my code:
Imports System.Windows.Forms
Imports System.ComponentModel
Public Class LCombo
Inherits ComboBox
Private m_blnLocked As Boolean
Private m_oldIndex As Integer
Public Property Locked() As Boolean
Get
Return Me.m_blnLocked
End Get
Set(ByVal value As Boolean)
m_blnlocked = value
End Set
End Property
Public Overrides Property SelectedIndex() As Integer
Get
Return MyBase.SelectedIndex
End Get
Set(ByVal Value As Integer)
m_oldIndex = Value
MyBase.SelectedIndex = Value 'Line XYZ
End Set
End Property
Sub New()
MyBase.New()
End Sub
Private Sub LCombo_SelectedIndexChanged(ByVal sender As Object,
ByVal e As System.EventArgs) Handles Me.SelectedIndexChanged
If Me.m_blnLocked Then
Me.SelectedIndex = m_oldIndex
End If
End Sub
Starting my program, I get an error at Line XYZ (see above).
"InvalidArgument=Value with Value 0 is for SelectedIndex invalid
Parametername: SelectedIndex
Do you have any idea? Is this possible at all?
Thanks
aaaPaul