Multiple ComboBoxes Using Same Collection For DataSource

Apr 21, 2009

I have two combo boxesthat use the same collection for their datasource. The data member and value member are also the same properties. When the form loads, and I select an item in one of the combo boxes, the same item is then selected in the other combo box. I want the combo boxes to work separately. Do I need to have two different collections, even though they would have the same data in them?

cboInboardKnife.DataSource = cKnives
cboInboardKnife.DisplayMember =
"Name"
cboInboardKnife.ValueMember =
"ToolID"
cboOutboardKnife.DataSource = cKnives
cboOutboardKnife.DisplayMember =
"Name"
cboOutboardKnife.ValueMember =
"ToolID"

View 1 Replies


ADVERTISEMENT

Use A My.Setting As Datasource For Multiple ComboBoxes

Apr 9, 2009

I want to maintain a list of potential ComboBox values over multiple executions of my program, and to use that list as the DataSource on multiple ComboBoxes. I also want changes made to the DataSource to propagate over all of the ComboBoxes already existing in the application.

Can someone recommend what type of object I should use as my DataSource, as My.Settings objects don't seem to support generic list objects.

Also, along with that recommendation, can I also ask for suggestions as to how to propagate the updates of the collection to all ComboBoxes? I would imagine I need a collection type which raises events when its contents change, but I can't think of any, and in any case do not know which are compatible with My.Settings.

View 1 Replies

Filter ComboBoxes DataSource Based On Another ComboBoxes Changes?

Oct 28, 2011

I have a form with 4 comboboxes and a button. The first combobox is enabled, but the rest of the controls are disabled. When the form is opened I fill the first combobox (cbxMethod) with a datatable. When the user selects something in cbxMethod the next combobox (cbxStudy) will be filled and so on. When the last combobox (cbxAnalyte) has a selected value I want to enable the button and give it focus so the user can move forward with the program. I basically want to force the user to move from one combobox to the other, until all are filled.I am currently using the SelectionValueChange event, but this event only fires when the user changes the value with their mouse or hits the Enter key, not when the user hits the Tab key.

Public Class frmCalculatedAnalyte
Private cv_dt As New DataTable
Public Sub New()

[code]....

View 8 Replies

Using Datatables As Datasource For Comboboxes?

Apr 20, 2010

I use single column datatables in combination with the .DisplayMember and .DataSource property to populate comboboxes. Data for these datatables I get from a MySQL database. All this is working fine, but I noticed some behavior for which I can't find an explanation, and am not sure of if it can be prevented somehow.Some of the datatables are used for different comboboxes on different tabs. The behavior found is that with comboboxes that have the same datatable as datasource. If I select an item in 1 combobox, the others automatically select the same item.

-Is this normal, because I couldn't find any documentation on this behavior?

-Can it be prevented, and if so how?

I could use a for next loop and manually add each item to the combobox, but using .DataSource is so much cleaner and more efficient.

View 6 Replies

.net - Windows Application That Populates Three Comboboxes From The Same Datasource

Jan 21, 2011

I was just writing a windows application that populates three comboboxes from the same datasource. My datasource is a datatable. The way i populate the comboboxes is by repeating the following code for each of the comboboxes:

'populate 1st combobox
cbx1.DataSource = table
cbx1.DisplayMember = "someColumn"
cbx1.ValueMember = "anotherColumn"
cbx1.SelectedIndex = Indx

[CODE]...

When the application is run, and I select an item from the dropdown list of, say, cbx1, my choice is reflected in cbx2 and cbx3 as well. I find this behaviour strange and will be grateful if anybody could explain what is going on here behind the scenes. On a side note, I've been able to circumvent this problem by modifying my code as shown below, but would still like to have an explanation for this seemingly strange behaviour.

'populate 1st combobox
Dim t1 as datatable = table.Copy
cbx1.DataSource = t1
cbx1.DisplayMember = "someColumn"
cbx1.ValueMember = "anotherColumn"
cbx1.SelectedIndex = Indx

[CODE]...

View 2 Replies

Pass A Collection Of Comboboxes To A Sub

Feb 6, 2010

I would like too generate a number of comboboxes at runtime and then pass them to a Sub, like this:[code]What is the correct syntax to use to pass the comboboxes collection to the Sub?

View 4 Replies

ComboBox - A Collection Of Classes Is The DataSource

Apr 5, 2011

I have a 2 classes, one is Employee, the other is Employees. Basically Employees is a collection of Employee, I have a combo box where the Datasource is Employees.

When the user selects a value from the combo box, How do I get an Employee object from whatever is selected?[code...]

It is an Infragistics combo box by the way.

View 1 Replies

Forms :: Et The Datasource On A ComboBox On A WinForm To Use The Above Collection?

Aug 3, 2011

I have a custom collection which is derived from a base class implementing IEnumerable and IEnumerator, this collection is populated with custom objects.I'm trying to set the datasource on a ComboBox on a WinForm to use the above collection - but when the code is run the ComboBox is always empty.

The code I was using was this:

Private Sub ViewSources_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
' declaration
Dim sourceCollection As SourceCollection
Dim source As Source

[code]....

View 6 Replies

Items Collection Cannot Be Modified When DataSource Property Is Set

Apr 27, 2010

I am trying to refresh my combobox when an item is selected and added the highlighted code as shown below; [code]Items collection cannot be modified when the DataSource property is set.

View 3 Replies

VS 2010 Determine Type In Collection In DataSource?

Sep 7, 2010

I am customizing a DataGridView control. The DataGridView is supposed to be bound to a collection of some type (be it a List(Of T) or ArrayList or whatever), and the idea is that one can easily determine (at design-time in this case) which properties of the type have to be shown in the grid and which column header name they should get. One can do this using an attribute. For example, if I have a class Person with Name, Age and HairColor and I don't want to show the HairColor property, and want to show the Name property as 'Person', I would use:

vb.net
Public Class Person
<Grid.GridOptions(displayName:="Person", visible:=True)> _
Public Property Name As String

[code]....

I do this during run-time by simply looping through the properties of the bound type (in this case Person), retrieving the GridOptions attribute (if any) and checking the values provided. This works just fine except for one thing: I'm not really sure how to determine the type in the databound collection...

At the moment, I cast the DataSource property to an IList and retrieve the type of the first instance in that list (if any). If there isn't a first instance (the list is empty) then I don't know how to get the type... Often I know that it will be impossible to know the type. If someone is binding an ArrayList for example, then it's impossible to know what kind of items he's going to put in that ArrayList. Even the normal DataGridView cannot show any columns when databound to an empty ArrayList. However, the framework's DataGridView does show the columns when bound to, for example, an empty List(Of Person), or a Person array.

I'm pretty sure that casting the DataSource to an IList is not the correct way as all information about the type of items in that list is then lost. But I'm not sure what else to cast it to... ITypedList? IBindingList? I even considered List(Of T) because that's all I am going to be using, but besides the fact that the grid would then obviously only work for a List(Of T) I still don't know how to do this... I don't know 'T' so I can't cast it to a List(Of T)...

View 2 Replies

"Items Collection Cannot Be Modified When The DataSource Property Is Set?

Jun 17, 2010

I have a combobobox on my form, and I use the following code to populate the data from SQL Server:

cbname.DataSource = DSAssetName.Tables(0)
cbname.DisplayMember = "IDWLNAME"
cbname.ValueMember = "FIDWID"

[code].....

View 2 Replies

VS 2008 Items Collection Cannot Be Modified When The DataSource Property Is Set

Feb 13, 2010

I have two tables "Person" and "Alias" in a one to many relationship. I have a DGV for "Person" and want to use a combobox for the Aliases. I also have a textbox and a button for the user to type the alias name and click the button to add the alias name to the combobox and update the dataset. I keep getting the "Items collection cannot be modified when the DataSource property is set." Error. But if i use a DGV instead of a combobox for aliases, I have no errors and everything works fine. If I remove the datasource property for the combobox it will not get populated with the data already entered, so how, or can I, set it up where the combobox gets populated when the form loads and able to add items to the combobox????

View 1 Replies

VS 2010 Items Collection Cannot Be Modified When The DataSource Property Is Set?

Aug 26, 2011

Like i want it to read the lines i have in the text file but i get an error Each time i press the button Why?

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Dim objreader As New System.IO.StreamReader("C:UsersJamesDesktopMusicas.txt")
Do Until objreader.EndOfStream

[code]....

Error:

Quote:

Items collection cannot be modified when the DataSource property is set.

Error line

Quote:

ListBox1.Items.Add(objreader)

View 7 Replies

Way To Populate Multiple Comboboxes From XML?

Aug 2, 2011

I have 3 comboboxes and want to populate each from XML. What is the best way to do this?Here is the XML:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<root>
<combobox name="cbScreenResolution">

[code]....

View 5 Replies

Cannot Manage Multiple ComboBoxes In Form

Jan 25, 2011

I have the following problem, a table "table1" contains 10000 telephone numbers, this table is source for 5 combo box contained in a form, I need that when I select the first tel N in the first combo, this number is not any more available for the combo 2, when I select the second number in the second combo, the first 2 numbers of the table 1 are not any more available for the combo 3 etc. Every record (in form) contains 5 combo. The Tel N selected into the combo are source for other table called "table2". I've try with all the type of query between table 1 and table 2, and use the result as source for the combo, I've try with IIf but this is works only for the first combo.

View 3 Replies

Iterate And Populate Multiple Comboboxes

Jan 29, 2012

I am trying to move over vb6 code that worked through arrays of comboboxes.I have a panel that has 18 comboboxes that each need to be populated the same.I first clear the combo boxes and it loops through them, but keeps going until it gets an error.Likewise on sFillLotNO, it adds the first foundrow to each but bombs out when it tries to get the 19th.[code]

View 2 Replies

VS 2008 - Choosing Between Multiple Comboboxes?

Nov 17, 2010

I have a program issue I am trying to work on. I have multiple comboboxes(12 total) on a form.I am attempting to update some settings from what ever the user selects from the combo boxes. I am trying to keep the code as small as possible, so I thought about having all the comboboxes have similar names only different by a number being changed at the end. (ex: cbo_1, cbo_2, cbo_3, etc...)And using a For next loop to advance through each combobox and update the settings as the for next loop advances.(This might be a stupid way of doing it, but its the first idea that came to mind.)

[code]...

View 1 Replies

Runtime Fill Multiple Comboboxes With Same Items?

Feb 22, 2010

I have 16 comboboxes with a naming convention of:

c1d2
c2d2
c3d2
c4d2
c16d2

These will all contain the same items and I need to add them at runtime. I know how to loop through the controls, but not sure how to make sure I'm only editing the correct comboboxes. (I will have to do this for 2 more sets of comboboxes with similar naming conventions as well)

View 4 Replies

VS 2008 Dataview Filter Multiple Comboboxes?

Feb 15, 2011

This post is a continuation of my other post concerning 'List(of) with multiple comboboxes refill problem.'. I threw the list overboard and began anew with a Dataview.

So far I (finally) managed to get 2 comboboxes (will be more, but if it works for 2...) loaded with the same data using different dataviews (DataView1 & DataView2) so I can select a value from each combobox without the other following the selection.

But now I want to filter out the selected value from the other combobox.
This also works.

The only thing is this: If I select in combobox1 the value 3, and select in combobox2 the value 4, combobox1 will change to the value 2.

If I select in combobox1 the value 2, and select in combobox2 the value 1, combobox1 will change to the value 3.

It works also the other way arround. I can't seem to get my hands around the problem..

Does somehow the index of the items in the combobox play's part? I don't use the selectedIndex, so from my point of view it can't be..

The code I use:
(with the item 0 as 'neutral' option)
Public Class Form1
Dim dTable As New DataTable

[Code].....

View 4 Replies

VS 2008 List(of) With Multiple Comboboxes Refill?

Feb 10, 2011

I'm trying to make a program in which I can import an excel file, read the whole thing and save it in another format. So far so good: can import the file, read it, skip first line or not etc.But.. Now I've been thinking about a sort option.What if the column order of the excel file is in another order than the export file must be in. In stead of opening the excel file and rearrange the columns manually, I would like to sort it in the program. Just for the sake of trying to make it work and gain experience

So, i read the first line which contains the column names and put them in several comboboxes where I can make a selection. No problem here.Now, the selection of combobox1 has to be removed from the other comboboxes and so on, to avoid double selections on one column. That's where my listOld comes in. Everytime a selection is made in a combobox, a sub is called to create the listOld and create the listNew (which contains items you can still choose from).As I make more selections the listOld gains more items and the ListNew grows shorter.But here comes the part where I'm puzzled.In the part "refill the comboboxes" (bottom part) when I disable "cmb2.Items.Clear()" the listOld (previous selected items) contains all selected items correctly.

[Code]...

View 1 Replies

[VB 2010] How To DISTINCT Values When Have Multiple ComboBoxes

Dec 8, 2011

I f I have 1 combobox then my SQL query will be:

Dim objConnection As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source = C:DB.mdb;Jet OLEDB:Database Password=Pass1;")
Dim objdataadapter As New OleDbDataAdapter("SELECT DISTINCT LOCATION FROM Table", objConnection)

View 5 Replies

How To Bind Multiple ComboBoxes To Same Data Source In Form

Oct 17, 2011

I have created a form with three comboboxes. means
FirstNameComboBox
MiddleNameComboBox
LastNameComboBox
All fields are select ( name ) from a "CustomerName" table. "CustomerName" table is have more than ten thousand records. I am use three binding sources its worked great but it is very slow bcz three comboboxes are filled data on form loading time. I am using visual studio 2010 (visual basic).

View 8 Replies

VS 2010 - Multiple ComboBoxes And Dropdown Lists With Different Items

Jul 16, 2010

I have multiple combox boxes,
A B C
Combobox B has items Fruit, Veg, Dairy
Combobox C needs to contain 3 list and depending on what value is selected in Combo Box B.

For example,
If I select Veg in Combo Box B, I would like to have a drop down list containing "tomatoes, lettuce, onion,..........."
If I select Dairy in Combo Box B, I would like to have a drop down list containing "Milk, Cheese...................."

View 8 Replies

Renaming ComboBoxes Causes Compiler - Cross Linked ComboBoxes?

Apr 24, 2012

this is a subset of a previously posted problem, I have narrowed down my issue and am reposting a question from this thread: [URL] I have apparently confused the compiler by renaming some comboboxes in Visual Basic .net express? (See relevant code below) I think the confusion is in who should handle what, with two routines named with variations of ComboBox1 and one handling the other ( it confuses me just trying to interpret it mentally):

[Code]...

View 5 Replies

C# - Using A Single DataSource On Multiple .NET Forms

Sep 16, 2010

My program has two forms which get data from the same data source. After binding controls to tables and fields on both forms, I noticed each form has it's own apparently duplicate DataSet. Is it standard practice for each form to have its own DataSet even though they use the same ConnectionString and connect to the same database at the same time?

View 1 Replies

Multiple Properties In A Collection

Aug 10, 2010

I want to create a collection with multiple properties.

View 15 Replies

Wpf - Add Multiple Classes To An Observable Collection?

Jan 30, 2012

I'm still teaching myself how to bind and use observable collection. One problem that I'm a little confused on is binding multiple classes/observable collection to one page. In other words, if I have a PersonName class and a AnimalName class, I have to create two separate observalbe collections for each? How would I set the datacontext when a page only allows one?

[code]...

Now If I add another class, how would I combine the two on the binding part and collection part.

View 2 Replies

Wpf - Multiple Views Of Observable Collection?

Mar 13, 2012

I've been working on this problem for a while and I'm clearly missing something...I create, populate and bind an observable collection like so:

Dim _ObservableWEI As New ObservableWEI
...
_ObservableWEI.Add(New WEI() With {.WEInum = 1, .WEIvalue = 1})[code].....

The problem is the filter effects the contents of both listboxes. I guess I need a specific instance of the collection to apply the filter too or something

View 1 Replies

Filtering A Collection With Linq And Multiple Criteria?

Jun 7, 2012

On my view there is a datatable holding a collection of ServerRow and 4 textboxes (Hostname, OS, Location, Zone). When the user types into any of the 4 boxes I want to immediately filter this list. I have this code setup and ready to go that on the set method of each textbox property I call the filter method.

Now onto the problem: if I have 4 criteria that means I have 2 to the power of 4 different scenarios. What I would like to do is write a linq statement with all of these scenarios dealt with such that if any of the properties are NullOrEmpty they will not be used in the Where clause and on the flip side if there is a value the corresponding field will be searched with a Contains.

Example

AvailableCis = New ObservableCollection(Of ServerRow)
(_CiData.Where(Function(ci) ci.OS.ToUpper
.Equals(_selectedOS.ToUpper) AndAlso
ci.HostName.ToUpper.Contains(_ciNameFilterText.ToUpper))
.OrderBy(Function(a) a.CiName))

This example shows how it works with 2 criteria and both of those criteria are set.

View 1 Replies

Looping A Collection Into Multiple New Filenames - How To Speed Up

Apr 6, 2010

i have the following snippet of

For Each tempstring In SourceDataCollection
LineToFieldsTemp = Split(tempstring, ",")
LineStringWithoutFirstEntry = "" 'reset the linestring
For i = 1 To UBound(LineToFieldsTemp)

[code]....

essentially what i'm doing is to read through each item in a collection of comma separated variable strings. the first variable in each string is appended to a master filename and becomes the NEW filename to which the entire string will be appended. this is a way to split a CSV file into multiple files using the first variable in that string.

the trouble is that this is doing a LOT of writes to potentially a LOT of files, the IO is taking forever. is there a way to buffer this data until the end, then write it to a disk? be aware, the filenames and total number of files to be created is UNKNOWN at the begining of the loop. it just creates a new file each time a unique first column ID is discovered.

View 13 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved