473,568 Members | 2,964 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

System.Argument OutOfRangeExcep tion occurred in system.windows. forms.dll

Dear all,

I've got a problem with my custom combo box.
When I select an entry from it, then I get the error message:

"An unhandled exception of type 'System.Argumen tOutOfRangeExce ption'
occurred in system.windows. forms.dll

Additional information: Specified argument was out of the range of valid
values."

Could you help me to get it running?

Thanks in advance for your help!

Best Regards,

HKSHK

Source Code follows:

Public Class HKSCBObjectColl ection
Inherits System.Windows. Forms.ComboBox. ObjectCollectio n

Dim vItemData() As Long

#Region "Constructo r"
Public Sub New(ByVal owner As System.Windows. Forms.ComboBox)
MyBase.New(owne r)
End Sub
#End Region

#Region "Add and Insert"
Public Shadows Function Add(ByVal Item As Object) As Integer
Return Add(Item, 0)
End Function
Public Shadows Function Add(ByVal Item As Object, ByVal ItemData As Long)
Dim t% = MyBase.Add(Item )
ReDim vItemData(t%)
vItemData(t%) = ItemData
Return t%
End Function

Public Shadows Sub Insert(ByVal Index As Integer, ByVal Item As Object)
Insert(Index, Item, 0)
End Sub
Public Shadows Sub Insert(ByVal Index As Integer, ByVal Item As Object,
ByVal ItemData As Long)
Dim t%
If Index > -1 And Index < Me.Count + 1 Then
If Index = UBound(vItemDat a) + 1 Then
Add(Item, ItemData)
Else
MyBase.Insert(I ndex, Item)
ReDim Preserve vItemData(Index + 1)
For t% = UBound(vItemDat a) To Index + 1 Step -1
vItemData(t%) = vItemData(t% - 1)
Next
vItemData(Index ) = ItemData
End If
End If
End Sub
#End Region

Private Sub CheckItemData()
Dim t%, t1%
t1% = UBound(vItemDat a)
If t1% <> Me.Count Then
ReDim Preserve vItemData(Me.Co unt - 1)
End If
End Sub

Public Property ItemData(ByVal Index As Integer) As Long
Get
CheckItemData()
Return vItemData(Index )
End Get
Set(ByVal Value As Long)
vItemData(Index ) = Value
End Set
End Property

#Region "Remove, RemoveAt and Clear"
Public Shadows Function Remove(ByVal Item As Object) As Integer
Dim t%
For t% = 0 To Me.Count - 1
If Me.Item(t%) = Item Then
RemoveAt(t%)
Return t%
Exit For
End If
Next
End Function

Public Shadows Sub RemoveAt(ByVal Index As Integer)
Dim t%, t1%
If Index > -1 Then
MyBase.RemoveAt (Index)
t1% = UBound(vItemDat a)
If Index < t1% Then
For t% = Index To t1% - 1
vItemData(t%) = vItemData(t% + 1)
Next
End If
ReDim Preserve vItemData(Index - 1)
End If
End Sub

Public Shadows Sub Clear()
MyBase.Clear()
ReDim vItemData(-1)
End Sub
#End Region

End Class

Public Class Testbox
Inherits System.Windows. Forms.ComboBox
Private vItems As New HKSCBObjectColl ection(Me)
Private vToolTip As New System.Windows. Forms.ToolTip

Public Shadows ReadOnly Property Items() As HKSCBObjectColl ection
Get
Return vItems
End Get
End Property

Protected Overrides Sub RefreshItem(ByV al index As Integer)
MyBase.RefreshI tem(index)
End Sub

Protected Overrides Sub SetItemsCore(By Val items As
System.Collecti ons.IList)
MyBase.SetItems Core(items)
End Sub
End Class
Jun 16 '06 #1
0 3460

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
9115
by: Terrence | last post by:
I am doing some of the C# walkthroughs to transition from VB to C#. When I try to execute static void Main() { Aplication.Run(new Form1()) } I raise a 'System.NullReferenceException" in system.windows.forms.dll
1
5956
by: gregory_may | last post by:
This code seems to "work" but I get the following errors: An unhandled exception of type 'System.NullReferenceException' occurred in system.windows.forms.dll then this one: An unhandled exception of type 'System.ExecutionEngineException' occurred in system.windows.forms.dll Anyone know how to either trap these errors or prevent them from...
11
3727
by: Andreas Wirén | last post by:
Hi I'm a C# .NET newbie doing a minor school project but I'm getting a strange error message. 'System.NullReferenceException' occurred in system.windows.forms.dll Additional information: Object reference not set to an instance of an object." As my references look I seem to be using the old framework(1.0.3705) for this, but re-referencing...
2
7796
by: Raed Sawalha | last post by:
i have a windows form(Main) with listview, when click an item in listview i open other window form (Sub) which generate the selected item from parent window in as treeview items when click any item in treeview i display the content item in axWebBrowser, i close the sub form normally when i close the main the following error is generated An...
1
1775
by: chintu rana via DotNetMonster.com | last post by:
An unhandled exception of type 'System.ArithmeticException' occurred in system.drawing.dll Additional information: Overflow or underflow in the arithmetic operation. if i run vb.net application with only form no any controls at that time there is no error . But if i put first control (command button or label or textbox ) and run...
2
2339
by: Graeme Neath | last post by:
I'm having a very bizarre problem. I have a vb.net application which uses the ESRI MapObjects 2.2 component (unmanaged code). When I use the MapObjects built-in function 'CopyMap' to copy the map to the clipboard my app will crash sometimes. Even stranger, sometimes if I copy the map to the clipboard (and my app doesnt crash immediately),...
3
31121
by: Pieter | last post by:
Hi, I have a Windows Forms application (VB.NET 2.0) which uses a Class Library in C#. The application runs fine, but when I run it in debug mode, I get several "A first chance exception of type 'System.ArgumentOutOfRangeException' occurred in mscorlib.dll" -exceptions that are shown in the Immediate window of Visual Studio 2005. I want...
0
1965
by: Mike | last post by:
Hi, I have a collection object bound to a data grid, after I remove an item from the collection, the minute I click on the datagrid I get an error saying the specified argument was out of the range of valid values. After I remove the element from the collection I clear the databindings from the data grid and rebind it but as far as I can...
5
8284
by: Henry Stock | last post by:
I am trying to understand the following error: Any thing you can tell me about this is appreciated. Security Exception Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's...
0
7693
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7604
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7660
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7962
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5498
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5217
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3651
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3631
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2101
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.