473,405 Members | 2,261 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,405 software developers and data experts.

adding extra items on top of ComboBox DataSource

Hi,

I have a ComboBox of +- 15.000 items in it, via a DataSource. On Top of the
Items-list, I want to add some values, based on a user choise (via a filter
on the DataSource). Does anybody know how I can do this? When just adding
them with ComboBox.items.Insert I get an "Items collection cannot be
modified when the DataSource property is set".

Does anybody has a solution for this? i'm surely not the first to do this
:-) I'm using VB.NET 2005 Beta 2.

Thanks a lot in advance,

Pieter
This is my source:

Dim dtbl As New DataTable
dtbl = MyWorkSpace.GetAllArticlesClient(61)

Dim dtv As New DataView(dtbl)
dtv.Sort = "NomArticle"

Dim dtvF As New DataView(dtbl)
dtvF.RowFilter = "NomArticle LIKE '*HUILE*'"
dtvF.Sort = "NomArticle"

Me.cmbTest.DataSource = dtv
Me.cmbTest.DisplayMember = "NomArticle"
Me.cmbTest.ValueMember = "CodeArticle"

Dim intX As Integer
For intX = (dtvF.Count - 1) To 0 Step -1
cmbTest.Items.Insert(0, dtvF.Item(intX))
Next
Oct 4 '05 #1
6 3121
I would just not set the datasource and insert them myself by looping
and then add the remaining

Oct 4 '05 #2
I'm afraid that it isn't fast enough :-/

I'm trying this now, and it takes alreaddy several seconds to add 50 rows
like that...

Dim dtbl As New DataTable
dtbl = MyWorkSpace.GetAllArticlesClient(61)

Dim dtv As New DataView(dtbl)
'dtv.Sort = "NomArticle"

Dim dtvF As New DataView(dtbl)
dtvF.RowFilter = "NomArticle LIKE 'POMPE*'"
dtvF.Sort = "NomArticle"

Me.cmbTest.DataSource = dtv
Me.cmbTest.DisplayMember = "NomArticle"
Me.cmbTest.ValueMember = "CodeArticle"

Dim intX As Integer
Dim drow As DataRow
For intX = (dtvF.Count - 1) To 0 Step -1
drow = dtv.Table.NewRow
drow(0) = dtvF.Item(intX).Item(0)
drow(1) = dtvF.Item(intX).Item(1)
drow(2) = dtvF.Item(intX).Item(2)
dtv.Table.Rows.InsertAt(drow, 0)
'cmbTest.Items.Insert(0, dtvF.Item(intX))
Next

"CMeStandingHere" <Ch***********@yahoo.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.com...
I would just not set the datasource and insert them myself by looping
and then add the remaining

Oct 4 '05 #3
Pieter,

I saw your datasource is a datatable, I would add a column to the datatable.
Than add the rows with in the NewColumn something as an A or whatever and
set the defaultview.Sort of the datatable to

Tabeleke.Datasoure = "Collomeke Desc"

I hope you like the idea.

Cor

"DraguVaso" <pi**********@hotmail.com> schreef in bericht
news:eH*************@TK2MSFTNGP10.phx.gbl...
Hi,

I have a ComboBox of +- 15.000 items in it, via a DataSource. On Top of
the Items-list, I want to add some values, based on a user choise (via a
filter on the DataSource). Does anybody know how I can do this? When just
adding them with ComboBox.items.Insert I get an "Items collection cannot
be modified when the DataSource property is set".

Does anybody has a solution for this? i'm surely not the first to do this
:-) I'm using VB.NET 2005 Beta 2.

Thanks a lot in advance,

Pieter
This is my source:

Dim dtbl As New DataTable
dtbl = MyWorkSpace.GetAllArticlesClient(61)

Dim dtv As New DataView(dtbl)
dtv.Sort = "NomArticle"

Dim dtvF As New DataView(dtbl)
dtvF.RowFilter = "NomArticle LIKE '*HUILE*'"
dtvF.Sort = "NomArticle"

Me.cmbTest.DataSource = dtv
Me.cmbTest.DisplayMember = "NomArticle"
Me.cmbTest.ValueMember = "CodeArticle"

Dim intX As Integer
For intX = (dtvF.Count - 1) To 0 Step -1
cmbTest.Items.Insert(0, dtvF.Item(intX))
Next

Oct 4 '05 #4
DraguVaso wrote:
I'm afraid that it isn't fast enough :-/

I'm trying this now, and it takes alreaddy several seconds to add 50 rows
like that...

Dim dtbl As New DataTable
dtbl = MyWorkSpace.GetAllArticlesClient(61)

Dim dtv As New DataView(dtbl)
'dtv.Sort = "NomArticle"

Dim dtvF As New DataView(dtbl)
dtvF.RowFilter = "NomArticle LIKE 'POMPE*'"
dtvF.Sort = "NomArticle"

Me.cmbTest.DataSource = dtv
Me.cmbTest.DisplayMember = "NomArticle"
Me.cmbTest.ValueMember = "CodeArticle"

Dim intX As Integer
Dim drow As DataRow
For intX = (dtvF.Count - 1) To 0 Step -1
drow = dtv.Table.NewRow
drow(0) = dtvF.Item(intX).Item(0)
drow(1) = dtvF.Item(intX).Item(1)
drow(2) = dtvF.Item(intX).Item(2)
dtv.Table.Rows.InsertAt(drow, 0)
'cmbTest.Items.Insert(0, dtvF.Item(intX))
Next

"CMeStandingHere" <Ch***********@yahoo.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.com...
I would just not set the datasource and insert them myself by looping
and then add the remaining



Why are you using InsertAt? I believe that it requires coping of all
the other current items to make room for the one item. If you do a
straight insert does it work at the same speed as the databind?
Oct 4 '05 #5
I use InsertAt, beauce I want them to be the first items to be shown in the
ComboBox, so I thought it is better to add them at the beginning...
A normal insert (Add) works indeed faster in my opinion.

"Chris" <no@spam.com> wrote in message
news:%2***************@TK2MSFTNGP15.phx.gbl...
DraguVaso wrote:
I'm afraid that it isn't fast enough :-/

I'm trying this now, and it takes alreaddy several seconds to add 50 rows
like that...

Dim dtbl As New DataTable
dtbl = MyWorkSpace.GetAllArticlesClient(61)

Dim dtv As New DataView(dtbl)
'dtv.Sort = "NomArticle"

Dim dtvF As New DataView(dtbl)
dtvF.RowFilter = "NomArticle LIKE 'POMPE*'"
dtvF.Sort = "NomArticle"

Me.cmbTest.DataSource = dtv
Me.cmbTest.DisplayMember = "NomArticle"
Me.cmbTest.ValueMember = "CodeArticle"

Dim intX As Integer
Dim drow As DataRow
For intX = (dtvF.Count - 1) To 0 Step -1
drow = dtv.Table.NewRow
drow(0) = dtvF.Item(intX).Item(0)
drow(1) = dtvF.Item(intX).Item(1)
drow(2) = dtvF.Item(intX).Item(2)
dtv.Table.Rows.InsertAt(drow, 0)
'cmbTest.Items.Insert(0, dtvF.Item(intX))
Next

"CMeStandingHere" <Ch***********@yahoo.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.com...
I would just not set the datasource and insert them myself by looping
and then add the remaining



Why are you using InsertAt? I believe that it requires coping of all the
other current items to make room for the one item. If you do a straight
insert does it work at the same speed as the databind?

Oct 5 '05 #6
I do indeed like the idea: I though of it myself yesterday. But won't it
take to much overhead adding the extra column? I'll try it today :-)

Thanks!

"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:uq**************@TK2MSFTNGP11.phx.gbl...
Pieter,

I saw your datasource is a datatable, I would add a column to the
datatable. Than add the rows with in the NewColumn something as an A or
whatever and set the defaultview.Sort of the datatable to

Tabeleke.Datasoure = "Collomeke Desc"

I hope you like the idea.

Cor

"DraguVaso" <pi**********@hotmail.com> schreef in bericht
news:eH*************@TK2MSFTNGP10.phx.gbl...
Hi,

I have a ComboBox of +- 15.000 items in it, via a DataSource. On Top of
the Items-list, I want to add some values, based on a user choise (via a
filter on the DataSource). Does anybody know how I can do this? When just
adding them with ComboBox.items.Insert I get an "Items collection cannot
be modified when the DataSource property is set".

Does anybody has a solution for this? i'm surely not the first to do this
:-) I'm using VB.NET 2005 Beta 2.

Thanks a lot in advance,

Pieter
This is my source:

Dim dtbl As New DataTable
dtbl = MyWorkSpace.GetAllArticlesClient(61)

Dim dtv As New DataView(dtbl)
dtv.Sort = "NomArticle"

Dim dtvF As New DataView(dtbl)
dtvF.RowFilter = "NomArticle LIKE '*HUILE*'"
dtvF.Sort = "NomArticle"

Me.cmbTest.DataSource = dtv
Me.cmbTest.DisplayMember = "NomArticle"
Me.cmbTest.ValueMember = "CodeArticle"

Dim intX As Integer
For intX = (dtvF.Count - 1) To 0 Step -1
cmbTest.Items.Insert(0, dtvF.Item(intX))
Next


Oct 5 '05 #7

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

Similar topics

0
by: stingrays | last post by:
Below is my code for a combobox. Basically, I have 2 comboboxes. 1 box is the application selection and the other retrieves data from the dataset (SQL Server) to populate the drop down in the...
6
by: vb | last post by:
Hi, I am new to .Net. I am using a Combo Box in my windows forms. I am adding the items by creating the instances and adding the same to the list. My questions/doubts are: 1. If I have 25 to...
6
by: DraguVaso | last post by:
Hi, I have a ComboBox of +- 15.000 items in it, via a DataSource. On Top of the Items-list, I want to add some values, based on a user choise (via a filter on the DataSource). Does anybody know...
0
by: VB Newbie | last post by:
I am creating a user control containing a combobox using VB.NET(2003) I want to add 2 public properties "DataSource" and "Items" like the "System.Windows.Forms.ComboBox" here is my code, but it...
5
by: VB Newbie | last post by:
I am creating a user control containing a combobox using VB.NET(2003) I want to add 2 public properties "DataSource" and "Items" like the "System.Windows.Forms.ComboBox" here is my code, but it...
14
by: Paul_Madden via DotNetMonster.com | last post by:
Basically I have a listbox to which I add simple STRING items- I have a progress bar which I increment whenever I populate another portion of the complete set of items I wish to add. What I observe...
0
by: marcobx | last post by:
I have a ComboBox and a List of objects to popolate items. I use the DataSource property and not the List collection: List<foolst = new List<foo>; //add elements into the list //......
3
by: =?Utf-8?B?Y2RtdW5veg==?= | last post by:
I have created a sub routine to programmatically add an indefinite number of combo boxes to a form. The combo boxes are bound in code to a view for displaying the available options. This routine...
6
by: Ken Foskey | last post by:
I am brand new to coding C# and Visual Studio. I have worked out how to configure the ComboBox creating my own object however it leave me with a lot of management updating as the table changes....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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.