Solved

How do I bind a datagrid to a listbox selected item?

Posted on 2006-07-10
6
195 Views
Last Modified: 2010-04-23
This is for VS2005.
I have one dataset created from a view created from 2 tables. I want the user to select a unit from the listbox and and then the datagridview will show what product is on that unit. I can do this by using a textbox.text property thru a button_click event where the user has to type in the actual unit name. I would like the listbox to show all the units when the form loads and the then the user to select the unit to show the list. I added the query, using @Unit as the variable in the query, FillByUnit.

CustomrerTableAdapter.FillByUnit(Dataset.Datatable, UnitNameListBox.SelectedItem)
This doesn't seem to work.

Thanks
0
Comment
Question by:grouchyfd
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 35

Expert Comment

by:YZlat
ID: 17076359
use DataView
0
 

Author Comment

by:grouchyfd
ID: 17076588
I don't understand. This is not a property of my listbox. Could you please explain a little more in depth?

Thanks
0
 
LVL 35

Expert Comment

by:YZlat
ID: 17076627
do you bind your DataGrid to a DataSet?
0
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 

Author Comment

by:grouchyfd
ID: 17076796
Yes I did.
0
 
LVL 35

Accepted Solution

by:
YZlat earned 500 total points
ID: 17076875
create a dataview based on your dataset:

Dim dv As New DataView(ds.Tables(0))

and then bind your datagrid to a dataview instead of a dataset.

Then you can ser RowFilter property of your dataview to whatever value user selects from  ListBox
0
 

Author Comment

by:grouchyfd
ID: 17076915
Because I'm using a view instead of a table I should use the dataview. That should work because I don't want the user to be able to edit anything.
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question