Can someone explain wiring between datagrid and a Find method?

L

Larry Woods

I have a combobox and a datagrid on a form (VB.NET). I have the DataSource
of each set to a datatable. I use the combobox "SelectedValue" to perform a
Find in the combobox SelectedIndexChanged event procedure.

Here is what confuses me: Performing the Find repositions the datagrid
display.

What "wiring" causes the datagrid to recognize that the Find was executed,
and where in the doc does it say that "Find" essentially repositions the
"current row" pointer in the data table?

Pertinent Information ( Source of data: SQL Server: Northwind ):

DataAdapter:

SQL="Select CustomerID, CompanyName from Customers" ; Select Only
(Dataset created)

DataGrid:
DataSource: Dataset.Customers

ComboBox:
DataSource: Dataset.Customers
DisplayMember: CompanyName
ValueMember: CustomerID

Form OnLoad event (1 statement):
DataAdapter.Fill(Dataset)

SelectedIndexChanged event (1 statement):

Dataset.Tables(0).Rows.Find(ComboBox.SelectedValue)

Any explanation will be greatly appreciated.

TIA,

Larry Woods
 
K

Kevin Yu [MSFT]

Hi Larry,

Based on my understanding, you're binding a data source to a ComboBox and a
DataGrid to and when changing the selected value in the ComboBox, the
current row changes accordingly.

This is because you're binding the same data source to two controls. When
you change the selected value in ComboBox, the position property in the
CurrencyManger changed. So the other controls which the data source is
binding to aware of this, and their selected items changed accordingly.

If you want to prevent this from happening, try to bind different data
sources with the control.

Does this answer your question? If anything is unclear, please feel free to
reply to the post.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

--------------------
| From: "Larry Woods" <[email protected]>
| Subject: Can someone explain wiring between datagrid and a Find method?
| Date: Sun, 19 Oct 2003 07:15:47 -0700
| Lines: 40
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
| Message-ID: <[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.adonet
| NNTP-Posting-Host: ip68-2-97-113.ph.ph.cox.net 68.2.97.113
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.adonet:63991
| X-Tomcat-NG: microsoft.public.dotnet.framework.adonet
|
| I have a combobox and a datagrid on a form (VB.NET). I have the
DataSource
| of each set to a datatable. I use the combobox "SelectedValue" to
perform a
| Find in the combobox SelectedIndexChanged event procedure.
|
| Here is what confuses me: Performing the Find repositions the datagrid
| display.
|
| What "wiring" causes the datagrid to recognize that the Find was executed,
| and where in the doc does it say that "Find" essentially repositions the
| "current row" pointer in the data table?
|
| Pertinent Information ( Source of data: SQL Server: Northwind ):
|
| DataAdapter:
|
| SQL="Select CustomerID, CompanyName from Customers" ; Select Only
| (Dataset created)
|
| DataGrid:
| DataSource: Dataset.Customers
|
| ComboBox:
| DataSource: Dataset.Customers
| DisplayMember: CompanyName
| ValueMember: CustomerID
|
| Form OnLoad event (1 statement):
| DataAdapter.Fill(Dataset)
|
| SelectedIndexChanged event (1 statement):
|
| Dataset.Tables(0).Rows.Find(ComboBox.SelectedValue)
|
| Any explanation will be greatly appreciated.
|
| TIA,
|
| Larry Woods
|
|
|
 
L

Larry Woods

Thanks, Kevin,

I'll dig into the CurrencyManager. (I have been putting it off until now!)

Larry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top