473,395 Members | 1,474 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,395 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
Nov 21 '05 #1
6 19608
I would just not set the datasource and insert them myself by looping
and then add the remaining

Nov 21 '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

Nov 21 '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

Nov 21 '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?
Nov 21 '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?

Nov 21 '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


Nov 21 '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: 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...
2
by: Chris | last post by:
I was wondering if there was any way to add a blank list item control to the beginning of the System.Web.UI.WebControls.DropDownList's datasource after the control's datasource has been specified....
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...
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
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.