473,396 Members | 2,013 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Adding blank line to combo box using Generics and BindingSource VB 2005

I've got a combo box that I want to bind a collection to. I got the
error "Complex Data Binding accepts as a data source either an IList or
an IListSource" so I tried using the BindingSource, which works except
when I want to have a blank line as the first item in the combo
box--then all that is displayed is the type of object.

Here is the code for filling the collection:

Public Function GetCollection(ByRef cndb As SqlConnection, Optional
ByVal addBlank As Boolean = True, Optional ByVal activeOnly As Boolean
= True) As SingleKeyCollection(Of KeyType, ObjectType)
Try
'Wrap the collection in the wrapper to properly load from
XML
Dim coll As New CollectionWrapper(Of KeyType, ObjectType)
'Be sure to convert all strings to db type paramaters using
db.todb()
coll = db.executeCollectionReader(cndb,
db.buildCommand(cndb, SP_GETS, PARAM_ACTONLY, activeOnly), coll)

If IsNothing(coll) Then
coll = New CollectionWrapper(Of KeyType, ObjectType)
End If
'If addBlank is true add a null ent
If addBlank Then

Dim blank As ObjectType =
Activator.CreateInstance(GetType(ObjectType))
With blank
.SetKey(CType(NULL_KEY_VALUE, KeyType))
.IsActive = True
.IsActiveSpecified = True
End With
'add the blank to the front of the collection
If coll.Items.Count = 0 Then
coll.Items.Add(blank)
Else
coll.Items.Insert(0, blank)
End If
End If

'return the collection
Return coll.Items

Catch ex As SQL_GerneralException
Throw New BL_SQLException(ex.Message)
Catch ex As SQL_UnknownSQLException
Throw New BL_SQLException(ex.Message)
Catch ex As Exception
Throw New BL_GeneralException(ex.Message)
End Try
End Function

Here is the code where I'm trying to fill the combo box:

Public Overridable Sub SetDropDowns(ByVal groupTitleCollection As
SingleKeyCollection(Of Integer, ContactGroupTitle_BO))
Dim bindingsource1 As New BindingSource

'Set the grouptitle datasource
'Me.cboGroupTitle.DisplayMember = "DisplayValue"
'Me.cboGroupTitle.ValueMember = "Key"
bindingsource1.DataSource = groupTitleCollection
Me.cboGroupTitle.DisplayMember = "DisplayValue"
Me.cboGroupTitle.ValueMember = "Key"
cboGroupTitle.DataSource = bindingsource1

End Sub

Now when I call the GetFunction to create a collection and I pass in
false for the optional parameter addBlank, the values I expect to be
displayed in the combo box are displayed but I want a blank line as
users don't always want to select a value and when I pass in true for
the optional parameter, then the type of groupTitleCollection is
displayed (and in this example, it's
BusinessLogic.ContractGroupTitle_BO. Any suggestions of what needs to
be changed?

Thanks.

Molly J. Fagan

Sep 18 '06 #1
0 1934

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

Similar topics

12
by: dan glenn | last post by:
Hi. I'm finding that if I have text entered into a <textarea ...> </textarea> in a form, and that text has leading blank lines (with no spaces or anything else), that when I retrieve the entered...
3
by: yanakal | last post by:
Hi, I'm using isql to query data and output the same to a flat file. The isql has the following command options ' -h-1 -w500 -n -b -s"" '. In the SQL_CODE, the first two lines before the select...
11
by: srinivas | last post by:
Hi all, I have one requirement.Is there any way to create a line graph using javascript.If it is please send me the sample code.But the thing is it should work in all browsers. Thanks,...
5
by: ChadDiesel | last post by:
My basic question is why does my print report button on my subform print a blank report when my cursor is on a blank entry line? Here is a more detailed explanation of my problem. I have a...
14
by: dave.dolan | last post by:
Basically I'd like to implement the composite design pattern with leaves that are either of reference or value types, but even using generics I can't seem to avoid boxing (using ArrayList or...
7
by: Joy M | last post by:
Hello, I am modifying an .asp file and I noticed that the top line on the screen is blank. I would like to remove this line, and push everything up to the top of the screen, but I don't know...
6
by: Timur Tabi | last post by:
Is there a way I can have the browser automatically insert a blank line after each definition in a definition list? Right now I have this: term-1 definition text .... term -2 definition text...
1
nev
by: nev | last post by:
Good day to all! I was trying to search the internet about this problem but I still can't seem to stumble upon an answer. I am using a BindingSource on my program and everything is ok except that...
1
by: brian mccallum | last post by:
My PHP code is generating XML with a blank first line before the <?xml version="1.0" ?> see http://urbanbees.co.uk/maps/phpsqlajax_genxml3.php I have been told this is the reason why my map...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.