Click here to Skip to main content
15,899,005 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
QuestionN-Hypernet in .net Pin
kamakshim2-Feb-09 2:59
kamakshim2-Feb-09 2:59 
AnswerRe: N-Hypernet in .net Pin
Colin Angus Mackay2-Feb-09 3:15
Colin Angus Mackay2-Feb-09 3:15 
GeneralRe: N-Hypernet in .net Pin
Mark Churchill2-Feb-09 13:30
Mark Churchill2-Feb-09 13:30 
AnswerRe: N-Hypernet in .net Pin
Pete O'Hanlon2-Feb-09 3:16
mvePete O'Hanlon2-Feb-09 3:16 
GeneralRe: NHibernate in .net Pin
kamakshim2-Feb-09 3:27
kamakshim2-Feb-09 3:27 
GeneralRe: NHibernate in .net Pin
Pete O'Hanlon2-Feb-09 3:36
mvePete O'Hanlon2-Feb-09 3:36 
Question"Configuration system failed to initialize" exception when upgradint to Visual Studio 2008 Pin
royk1231-Feb-09 23:39
royk1231-Feb-09 23:39 
QuestionFiltering a Datagridview with an external Combo Box Pin
Kumungi1-Feb-09 18:44
Kumungi1-Feb-09 18:44 
Hi All, (using Vb.net & VS 2008)

I have the following problem which has stumped me for the last few days Confused | :confused: :

I have a form with a Datagridview showing products ordered by customers over a 14 day period.

Also on the form I have an external combo box. The combo box is populated with customer names.

My plan is to have the user select a customer name via the external combo box then have the datagridview filtered with orders for the selected customer for the 14 days

So far, this is what is happening :

The Datgridview displays orders for All customers correctly over 14 days
The combo box displays a drop down list of All customers correctly

So far this is not happening :

Selecting a customer from the combo box doesn't change the datagridview to show only the selected customer orders. Orders from all customers show regardless of which customer is in the combo box selection.

Here is the code I am using :

-----------------------------------------------------------------------------------------------
Private Sub btnConnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConnect.Click

Dim connection As SqlCeConnection = New SqlCeConnection()
connection.ConnectionString = "Data Source=\SD Card\DB.sdf;"

connection.Open()

'Populate the orders datatable from the Order table
Dim da As SqlCeDataAdapter = New SqlCeDataAdapter("SELECT my select statement goes here", connection)

Dim mybindingsource As New DataTable

da.Fill(mybindingsource)
DataGridView1.DataSource = mybindingsource

'Populate the Combo Box with Cust ID & Names from the Account table
Dim cboda As SqlCeDataAdapter = New SqlCeDataAdapter("SELECT ID, AccountName FROM Account", connection)
Dim cbods As DataSet = New DataSet

cboda.Fill(cbods, "Account")

Dim dt As New DataTable

dt.Columns.Add("ID", GetType(System.String))
dt.Columns.Add("AccountName", GetType(System.String))

Dim drcbods As DataRow
Dim drNewRow As DataRow

For Each drcbods In cbods.Tables("Account").Rows()
drNewRow = dt.NewRow()
drNewRow("ID") = drcbods("ID")
drNewRow("AccountName") = drcbods("AccountName")
dt.Rows.Add(drNewRow)
Next

cboCustomers.DropDownStyle = ComboBoxStyle.DropDownList
With cboCustomers
.DataSource = New DataView(dt)
.DisplayMember = "AccountName"
.ValueMember = "ID"
End With

-------------------------------------------------------------------------------------
I have the following code under the Combo box selectedValueChanged event

Private Sub cboCustomers_SelectedValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboCustomers.SelectedValueChanged

Me.myBindingSource.Filter = "Account_ID= '" & cboCustomers.SelectedValue.ToString & "'"

-------------------------------------------------------------------------------------

Fields in the Order datatable are : Account_ID, AccountName, Product_ID, ProductName, OdrQty1,......OrdQty14

Fields in the Account datatable are : ID, AccountName

In the underlying DB the Account and Order tables are linked via Account.ID = Order.Account_ID

I greatly apperciate any advice or assistance.

Many Thanks

Ku Mungi
AnswerRe: Filtering a Datagridview with an external Combo Box Pin
Wendelius2-Feb-09 6:54
mentorWendelius2-Feb-09 6:54 
GeneralRe: Filtering a Datagridview with an external Combo Box Pin
Kumungi2-Feb-09 17:17
Kumungi2-Feb-09 17:17 
GeneralRe: Filtering a Datagridview with an external Combo Box Pin
Kumungi3-Feb-09 1:44
Kumungi3-Feb-09 1:44 
GeneralRe: Filtering a Datagridview with an external Combo Box Pin
Wendelius3-Feb-09 7:01
mentorWendelius3-Feb-09 7:01 
Questionset up project Pin
hrishiS31-Jan-09 2:10
hrishiS31-Jan-09 2:10 
Question[Message Deleted] Pin
svt gdwl30-Jan-09 23:11
svt gdwl30-Jan-09 23:11 
AnswerCross-post Pin
Wendelius30-Jan-09 23:33
mentorWendelius30-Jan-09 23:33 
QuestionNumber formats Pin
PIEBALDconsult30-Jan-09 16:16
mvePIEBALDconsult30-Jan-09 16:16 
AnswerRe: Number formats Pin
Wendelius30-Jan-09 23:56
mentorWendelius30-Jan-09 23:56 
GeneralRe: Number formats Pin
PIEBALDconsult31-Jan-09 3:48
mvePIEBALDconsult31-Jan-09 3:48 
GeneralRe: Number formats Pin
Wendelius31-Jan-09 4:05
mentorWendelius31-Jan-09 4:05 
GeneralRe: Number formats Pin
PIEBALDconsult31-Jan-09 5:33
mvePIEBALDconsult31-Jan-09 5:33 
GeneralRe: Number formats Pin
Wendelius31-Jan-09 6:01
mentorWendelius31-Jan-09 6:01 
GeneralRe: Number formats Pin
PIEBALDconsult31-Jan-09 11:18
mvePIEBALDconsult31-Jan-09 11:18 
GeneralRe: Number formats Pin
Wendelius31-Jan-09 11:26
mentorWendelius31-Jan-09 11:26 
GeneralRe: Number formats Pin
PIEBALDconsult31-Jan-09 11:28
mvePIEBALDconsult31-Jan-09 11:28 
GeneralRe: Number formats Pin
Wendelius31-Jan-09 11:31
mentorWendelius31-Jan-09 11:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.