vb 2012 how do I make independent listboxes from data records? - vb.net

Very new to visual studio 2012.
I'm trying to select labour in the top listbox and the excavator in the bottom listbox. When I select the bottom listbox as excavator, the top listbox changes to the excavator as well. How do I make these independent?? The listboxes are looking up a data table where each resource/selection is a row/record. I only want to look up the resource record and not modify the record and the user inputs the quantity manually.

It seems you are binding the same object as source to these two list boxes.
If your DataTable name is dt, use dt.AsEnumerable() as DataSource to each of your list box.

Related

vb.net create tabpages and datagridview from list exported from SQL

Just after some ideas on the best way to create additional tabpages dynamically within a tabcontrol and also to then add the relevant data on each tab with a datagridview.
The tabcontrol will always exist, but I'm not sure whether to initially create the additional tabpages first by identifying the distinct data in SQL, and then run a further script to extract the data, which then needs to be added to the datagridview, or whether I can use vb.net to create the distinct tabpages and add the data from one table, as below.
I can add another tabpage dynamically but not sure the best way to do it for a list, that is extracted from SQL.
Hope that makes sense. Thanks
TabCode
TabName
DataName
DataType
1
One
Test Name
Text
1
One
Test Date
Date
2
Two
Test Value
Value
I've managed to create new tabpages, but only single instances as not sure how to create them from a list extracted from SQL. I'm then struggling to add the data to the relevant datagridview, which I envisage would be created with a name linked to the tabpage name.

Visual Studio 2010 create a table like excel for input data

I am using Visual Studio Express, and I am tryng to add a form to my Windows application with rows and columns, but I cannot find any WindowsForm like a table or cells design.
I tried to create diferrents Textbox, but I need around two columns and 10 rows with a title and its not practical to add many textboxes.
You're looking for the DataGridView control:
http://msdn.microsoft.com/en-us/library/e0ywh3cz.aspx

creating a ComboBox in MS Access to hold distinct types

I am trying to create a combo box in an Access form to display all the types in an inventory list (ex. cables, UPS, shelves, ...)
When I make the row source for the ComboBox I only want the type to display there once. The ComboBox will later be used to make a report for the different types of items in the inventory, so I will only need each type in the list box once. These types can be changed later so I want the list to be updated automatically.
Right now I have the ListBox displaying all the types multiple times, but when I try to change the row source to:
Select Distinct Inv_Type
From Inventory;
I just get an empty ComboBox. But when I query that code I get get each type only once (this is what I want). What am I doing wrong? Why am I getting an empty ComboBox?
Doing as what Remou said; I created a ComboBox from scratch, without using the wizard first fixed my problem. Thanks!

how to populate textbox with the database value based on combobox change in access

I am new to Access and vb and i have failed to get the result what i am thinking to get ,hope i will resolve with your help guys
->my access database contains one table with following fields
firstname lastname middlename phone
I have two combo boxes and two textboxes
combobox- it populates firstname and based on this selection the other combo box has to fill with last name which i did successfully with the help of Me.Combo2.Requery
but i dont know how to fill middle and phone in textboxes
here i am failing in mapping recordset and connectionstring with my table and getting result to textbox value can any one help on this
You still have not said where the connection string comes from or why. The big advantage of Access is that it is fast and easy, for the most part, you do not need connection strings.
First, select your table, then choose create form. This will create a single form bound to the table. You could have created a query first and chosen that instead.
That is it. You have a form that displays your data. The key to this is the property sheet for the form, which you can find by switching to design view and double-clicking the small square at the top left of the form just under the form name. The property sheet will show the name of the table or query on the Data tab under the Record Source propery. You can, of course, set this property manually.
You can now add a combobox to select records, but you do not have to, there are navigation buttons at the bottom of the form.
To add a combobox that selects records on your form, you must have first bound a recordset to your form using the steps above. Next, ensure that the wizard is selected for the toolbox. Unless you have unselected it, it will be selected. Now choose combobox from the toolbox, it will open the wizard.
Choose find a record on my form and press next to choose the relevant ID field / column and any other fields that you need. When the wizard completes, in MS Access 2010 (and probably in 2007) it will add an embedded macro that finds your record and in earlier versions it will add code. Other properties set by the wizard will look something like this:
Row Source : SELECT ID, Firstname, Lastname FROM Table1
Column Count : 3
Column Widths : 0cm;2.54cm;2.54cm
Your table should have an ID, add one before you start, if it does not. The wizard will not add a Control Source when this option is selected because it is not needed, in fact, it would be a disaster to add a Control Source to a combo that finds records. Once again, you can do this manually. The code to find a record might look something like:
Private Sub MyCombo_AfterUpdate()
With Me.Recordset
.FindFirst "ID=" & Me.MyCombo
End With
End Sub
This works because the bound column of the combo is set to 1, the first field of the select statement, which is ID.
The combo includes two other fields / columns and you can refer to these in a textbox by setting the control source of the textbox to:
= MyCombo.Column(2) ''Lastname
Where you count columns from zero:
Row Source : ID (0), Firstname (1), Lastname (2)
Cascading combos are another story altogether, and you can read it here How to synchronize two combo boxes on a form in Access 2002 or in Access 2003 and here Is there a simple way of populating dropdown in this Access Database schema?

Updatable Label text according to combobox filled with an Acces database

Hi I'm using Visual Basic 2008 Express Edition, so I have a combobox that gets filled with items from a data base made with Microsoft Acces, the combobox is filled with the values stored in a column from a table in de database so the user can select an "option" from it, I want to add labels that show the values for the corresponding row of that column. I used the Data Source panel to drag and drop the labels corresponding to the values that I want and it works it show the value that I want when I compile the application (at least I think it does, it could be that it's only selecting the first entry) the problem is that when I select a diferent entry on the combobox the labels don't refresh with the new values. How can I do that?
edit
Ok soo I guess my real question is how does Visual Basic Populates de combobox and gets the value of the other Acces DB entrys to change the .text value of the labels? And I mean the actual code that does that.
See if this helps at all
Put some code in the on_click event of the combo box to change the label captions appropriately.
Ok I figured it out, apereantly Visual Creates new data sources each time you drag and drop an item from the Data Sources Panel so all you have to do is make sure that VB is using the same data source used in the combo boxes and the labels so they will update automatically when you choose an option from the combo box, I did it by finding the proper elements in the Form1.Designer.vb file of my project and editing 'DataBindings.Add' property of the labels.