473,664 Members | 3,035 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Get AllArticlesClie nt(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.Data Source = dtv
Me.cmbTest.Disp layMember = "NomArticle "
Me.cmbTest.Valu eMember = "CodeArticl e"

Dim intX As Integer
For intX = (dtvF.Count - 1) To 0 Step -1
cmbTest.Items.I nsert(0, dtvF.Item(intX) )
Next
Oct 4 '05 #1
6 3143
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.Get AllArticlesClie nt(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.Data Source = dtv
Me.cmbTest.Disp layMember = "NomArticle "
Me.cmbTest.Valu eMember = "CodeArticl e"

Dim intX As Integer
Dim drow As DataRow
For intX = (dtvF.Count - 1) To 0 Step -1
drow = dtv.Table.NewRo w
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

"CMeStandingHer e" <Ch***********@ yahoo.com> wrote in message
news:11******** *************@g 14g2000cwa.goog legroups.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.Sor t of the datatable to

Tabeleke.Dataso ure = "Collomeke Desc"

I hope you like the idea.

Cor

"DraguVaso" <pi**********@h otmail.com> schreef in bericht
news:eH******** *****@TK2MSFTNG P10.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.Get AllArticlesClie nt(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.Data Source = dtv
Me.cmbTest.Disp layMember = "NomArticle "
Me.cmbTest.Valu eMember = "CodeArticl e"

Dim intX As Integer
For intX = (dtvF.Count - 1) To 0 Step -1
cmbTest.Items.I nsert(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.Get AllArticlesClie nt(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.Data Source = dtv
Me.cmbTest.Disp layMember = "NomArticle "
Me.cmbTest.Valu eMember = "CodeArticl e"

Dim intX As Integer
Dim drow As DataRow
For intX = (dtvF.Count - 1) To 0 Step -1
drow = dtv.Table.NewRo w
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

"CMeStandingHer e" <Ch***********@ yahoo.com> wrote in message
news:11******** *************@g 14g2000cwa.goog legroups.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******** *******@TK2MSFT NGP15.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.Get AllArticlesClie nt(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.Data Source = dtv
Me.cmbTest.Disp layMember = "NomArticle "
Me.cmbTest.Valu eMember = "CodeArticl e"

Dim intX As Integer
Dim drow As DataRow
For intX = (dtvF.Count - 1) To 0 Step -1
drow = dtv.Table.NewRo w
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

"CMeStandingHer e" <Ch***********@ yahoo.com> wrote in message
news:11******** *************@g 14g2000cwa.goog legroups.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******** ******@TK2MSFTN GP11.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.Sor t of the datatable to

Tabeleke.Dataso ure = "Collomeke Desc"

I hope you like the idea.

Cor

"DraguVaso" <pi**********@h otmail.com> schreef in bericht
news:eH******** *****@TK2MSFTNG P10.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.Get AllArticlesClie nt(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.Data Source = dtv
Me.cmbTest.Disp layMember = "NomArticle "
Me.cmbTest.Valu eMember = "CodeArticl e"

Dim intX As Integer
For intX = (dtvF.Count - 1) To 0 Step -1
cmbTest.Items.I nsert(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
630
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 otehr box. I want to make a selection in the app combobox, update the second box and when I select a new app, it should remove all items in teh 2nd combobox and refresh the list with only the selected app. With this code it appears the binding is...
6
2664
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 30 options in each combo box and like that if we have 6 or 7 combo boxes in a form, isnt it a problem in creating that number of instances everytime the form is opened/activated 2. How do I dispose the Combo Box items.
6
19625
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 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...
0
1462
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 doesn't work. What's wrong with it? Public Property cboDataSource() As Object Get Return Me.cbo.DataSource 'cbo is my combobox End Get
5
6900
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 doesn't work. What's wrong with it? Public Property cboDataSource() As Object Get Return Me.cbo.DataSource 'cbo is my combobox End Get
14
18713
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 is that as more and more are added, population of the list box takes longer and longer. ie the first 10th of the item set are added much much quicker than the last 10th. THis occurs with about 40,000 listbox items. My worry is the listbox may...
0
1897
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 //... comboBox1.DataSource = lst; This work fine, items appear. Now I have a button near the combo box and I want to add a new element
3
1835
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 works good until you add the second combo box. At that point it changes the first combo box's selected item. A third changes the second and first and so on. I've tried setting the combo box name and tag to a unique name, but that doesn't help. ...
6
1686
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. I would like to add to the table, so if you think sport, a game is played in a stadium that is located in a country. game has one venue has one country
0
8437
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8861
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8549
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
8636
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7375
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5660
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4351
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2003
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1759
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.