Combo Box add Value too
Combo Box add Value too
Combo Box add Value too
Combo Box add Value too
Combo Box add Value too
Combo Box add Value too Combo Box add Value too Combo Box add Value too Combo Box add Value too Combo Box add Value too Combo Box add Value too Combo Box add Value too Combo Box add Value too
Combo Box add Value too Combo Box add Value too
Combo Box add Value too
Go Back  Xtreme Visual Basic Talk > > > Combo Box add Value too


Reply
 
Thread Tools Display Modes
  #1  
Old 01-27-2011, 11:59 AM
nate's Avatar
nate nate is offline
Junior Contributor
 
Join Date: Mar 2001
Posts: 358
Default Combo Box add Value too


I have this in a separate class file:

Code:
Imports Microsoft.VisualBasic

Public Class cboAddItem

    Public Value As String
    Public Item As String

    Public Sub New(ByVal NewItem As String, ByVal NewValue As String)
        Value = NewValue
        Item = NewItem
    End Sub

    Public Overrides Function ToString() As String
        Return Item
    End Function

End Class
I then use this in my page code:

Code:
cboBusinessCategory.Items.Add(New cboAddItem("Show All", "1"))
What am I missing or doing wrong? I get the intellisense error overload, add cannot be called with these arguments. cboAddItem can not be converted to string/listitem.

Thanks in advance.
__________________
Ignorance begins with I.
Reply With Quote
  #2  
Old 02-23-2011, 04:44 PM
DoughBoy DoughBoy is offline
Centurion
 
Join Date: Jun 2006
Posts: 196
Default

Hi nate,

Your custom List-Item is not compatible with the Combo Box. When you type in the code:
Code:
cboBusinessCategory.Items.Add(
At this point, IntelliSense will kick in and identifies what type of objects can go here. Your custom List-Item needs to "Inherit" (if it can) the proper item object's class.

I hope this guides you into solving your issue. Please post back if you have more questions.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Combo Box add Value too
Combo Box add Value too
Combo Box add Value too Combo Box add Value too
Combo Box add Value too
Combo Box add Value too
Combo Box add Value too Combo Box add Value too Combo Box add Value too Combo Box add Value too Combo Box add Value too Combo Box add Value too Combo Box add Value too
Combo Box add Value too
Combo Box add Value too
 
Combo Box add Value too
Combo Box add Value too
 
-->