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


ADVERTISEMENT

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

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

Setting Values To Options In ComboBoxes

May 27, 2010

I'm using VB 2010 and I'm trying to use combo boxes on a current project but I'm not familiar with the code. I would like to set values to certain options in the combo box.

For example, if inside the combo box I listed the options:
Dog
Cat
Bird

I want dog to be set to = 1
cat = 5
bird = 12

To go further into depth, the code probably looks something like:
If cat.selected then
pet = 1

View 2 Replies

Asp.net - Error When Setting The Datasource For A Gridview?

Apr 7, 2009

I have a gridview. Its datasource is set as follows.dtTable is a datable in which the values for the table will be retrieved. But when setting dtTable as datasource I get an error "Object reference not set to an instance of an object". What may be the reason for this?

gridview.Datasource = dtTable
gridview.Databind()

View 3 Replies

Setting DataSource Connectionstring At Runtime?

Dec 22, 2011

I am kind of an old 'newbee' at this, so bear with me for a moment. I am developing a windows forms application in Visual Studio 2010 Professional that connects to a remote database (MS sqlServer 2008 R2).To speed up development, I configured a DataSource and used the data objects associated with it. In VB6,
the data source could be assigned to the data objects during runtime using a variety of different runtime database connections, ODBC, ADO, ...

I have been unable to find a similar method with the VS2010 Visual Basic DataSource and underlying TableAdapter, BindingSource, BindingNavigator, down to the individual ComboBox and assorted other bound controls. It's convenient to have the integration, but I've got different users with different permissions, The long and short is that I'd like to be able to assign the data source during runtime operation, at least to the connection string level.

View 9 Replies

Setting Report Datasource To Datagridview?

Jun 11, 2011

My current problem is this:I have a form and I have in it three textboxes, 1 button and 1 datagridview; I also have an acceI'm learnig now on how to create a report without a database. But In how to set the datagriview as the datasource for my report

View 8 Replies

Removing Items From A List Box After Setting The DataSource

Sep 29, 2010

I have a small requirement and that is as follows:

I am populating a ListBox using stored procedures and the ListBox is populated as follows:

lstItems.DisplayMember = "emp_name"
lstItems.ValueMember = "login_id"
lstItems.DataSource = accessFunction.getEmployees

The ListBox gets populated correctly. After it is populated, i have a CommandButton and on the click event of the button, i want to remove selected items from the ListBox. So in the click event of the CommandButton, i have written the following code:

lstItems.Items.Remove(lstItems.SelectedItem)

After selecting an item from the ListBox and when i click the CommandButton, i get an error as "Items collection cannot be modified when the DataSource property is set".

how i can delete items from the ListBox.

View 2 Replies

VS 2008 How To Remove XStopBits (0) Before Setting DataSource

Jan 21, 2010

[code]My question is how can I remove xStopBits(0) before setting the DataSource?To get around this I currently have a check in the ComboBox1_SelectedIndexChanged event.

View 14 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

DataGridComboBoxColumn Setting And Retrieving Combobox Row With Access Datasource?

Jan 3, 2010

I have a datagridview that is populated using an oledbconnection:

Private Sub FileSpecs_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim cn As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & My.Settings.DBLocation & ";")Dim cmd As OleDbCommand = New OleDbCommand("SELECT specFieldno AS [Field No],specFieldName AS [Field Name], specFieldType FROM fileSpecs WHERE ClientNo='" & ClientSetup.clientNo.Text & "' AND direction=" & ClientSetup.fileDir, cn)

[Code]...

The problem I now face is that the 'index' value of the combobox item for each row is in the field specFieldType which is populated into the datagrid.I need to be able to set the value of the ComboBox for each row when the form is opened, and also be able to save the index value of each row selection if any changes are made/saved.

View 3 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

Unable To Cast Object Of Type X To Type X On Setting DataSource To A Table?

Feb 19, 2012

Columns 0 & 1 are filled from a DataAdapter from Access Database and three are added. I had this working, but I changed it to check for the column "Feed" so I could add several Locations. At first this worked,but I did someething in perfecting it and it now fails after filling the first row of the datagridview (dgvFdMed).I ran a check and the table LotsTab has 8 rows filled. Column 1 & 2 are strings and the database appears they are fine. The added columns have just been created with no value. My plan is to enter the values and then use the data from the grid.

Private Sub sfillGrid(ByVal Loc As String)
Dim i As Integer
Dim column As DataGridViewColumn

[code]....

View 12 Replies

Datagridview Bound To A Datatable Setting Its Datasource Property To The Datatable

May 20, 2011

I have a datagridview bound to a datatable setting its datasource property to the datatable. I would like to have a child form that contains a list of columns associated with the datatable that contains a checkbox that will allow the user to hide and show the columns ( I do not know the best control to use here) (I assume this is the easy part as All i need to do is loop through each of the datatable's columns to get the column name)

now I would like save these visible columns on some event like form_closing so that the next time the user opens the form up it will remember the settings

View 5 Replies

Custom Setting To Save Multiple Instances

Dec 28, 2011

I have this code for custom settings:

Code:
Imports System.Configuration
Public Class setLV
Inherits ApplicationSettingsBase
Private fpListViewItems As List(Of ListViewItem)
ReadOnly Property ListViewItems() As List(Of ListViewItem)
[Code] .....

It works great for saving one Listview and its items but I need to save multiple Listviews and their items. I have no idea how to accomplish this.

View 3 Replies

Pixel Density Across Multiple Machines - Setting?

Apr 2, 2011

I have been working on a suite of VB 2008 Express applications on my laptop and thought I would do some work on them using my main desktop rig. I have the VB 2008 Express IDE on both machines, identical MySQL database, Apache Server, etc etc. Everything works fine except that the forms look a little different on my desktop.

Different meaning that the controls don't quite line up correctly as far as spacing, and I have two bitmap graphics on the forms (logos) that appear the same size, but the picture box is smaller, on my desktop than they do on my laptop, so they are cut off.

Additionally, when I add my text box controls and set their location, they are WAY off on my desktop but line up correctly on my laptop.

Both my laptop and my desktop use Windows XP Pro (laptop is the Media Edition however) and I use the same resolution screens (1680x1050).

So I was wondering if it might be a DPI Pixel Density difference, and how I might go about checking that and adjusting it.

Here are two images showing the subtle differences between machines. Of course, it would be ideal if I could get my forms to look identical across both machines.

View 1 Replies

Change Microsoft SQL Server (SqlClient) Datasource To ODBC Datasource?

Jan 30, 2011

I use vb.net and windows form and sqlserver

I added Data Source(Microsoft SQL Server (SqlClient)) to my project. and now I need to change it to ODBC Data Source .

View 1 Replies

VB 2005 - Multiple PictureBoxes And Setting Up Control Array

Sep 7, 2005

I have a VB2005 project that displays 16 pictureboxes in a 4x4 grid which display CD album covers. In VB6 I could set up a control array i.e. picCD(0) to picCD(15), which made drawing the CD covers a snap. How do I accomplish this in VB2005?

It seems extremely cumbersome to have code like: If Len(path(0)) < 1 Then
If Not IsNothing(PictureBox1.Image) Then
PictureBox1.Image.Dispose()
PictureBox1.Image = Nothing
End If
[Code] .....

View 5 Replies







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