By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,435 Members | 1,967 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,435 IT Pros & Developers. It's quick & easy.

BindingManagerBase.Position and Table.Rows.Find

P: n/a
How do I retrieve the position value after successfully finding the row that
I'm looking for? I need to set

BindingManagerBase.Position

so that all of the controls on the form are synchronized. Is there another
way of moving to a particular record within a dataset given the value of the
key?

Nov 17 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Christopher,

Because this is a base class is this not the way to go.

Have a look at this page, there is a lot of explanation too.
Currencymanager

http://msdn.microsoft.com/library/de...classtopic.asp

I hope this helps,

Cor
Nov 17 '05 #2

P: n/a
Hi Christopher,

As you use complex data binding, do the following:

CurrencyManager cm = (CurrencyManager)this.BindingContext[theDataTable];
DataView dv = (DataView)cm.List;

// Search the row in the DataView by its key.
// We need the index of the row in the DataView, not the source DataTable.

cm.Position = foundRowIndex;

--
Sincerely,
Dmytro Lapshyn [Visual Developer - Visual C# MVP]
"Christopher Weaver" <we*****@verizon.net> wrote in message
news:OQ**************@TK2MSFTNGP09.phx.gbl...
How do I retrieve the position value after successfully finding the row
that I'm looking for? I need to set

BindingManagerBase.Position

so that all of the controls on the form are synchronized. Is there
another way of moving to a particular record within a dataset given the
value of the key?


Nov 17 '05 #3

P: n/a
Here's what I've tried so far:

The declaration in the form's class definition:
private CurrencyManager ByNames_cMgr;

In the form constructor:
ByNames_cMgr = (CurrencyManager)this.BindingContext[dsAssignedBy1,
"Table"];

In the DropDown event handler for the ComboBox:

ComboBox cb = (ComboBox)sender;
DataTable dt = (DataTable)cb.DataSource;
string cbText = cb.Text;
int rowIndex;
try
{
try
{
Cursor.Current = Cursors.WaitCursor;
odbcDA_Names.Fill(dt);
DataView dv = new DataView(dt);
dv.Sort = "Name";
rowIndex = dv.Find(cbText);
MessageBox.Show(rowIndex.ToString());
ByNames_cMgr.Position = rowIndex;

etc....

The MessageBox.Show call confirms that I've actually found the index of the
row that I'm looking for, but the Position assignment doesn't move the
pointer within the ComboBox dropdown list to that record.

Any help you can give will be greatly appreciated.
Nov 17 '05 #4

P: n/a
Please have look at my reply to Dmytro's post.

Thanks for your help!
Nov 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.