hi
i bounded the same dataview to 2 different comboboxes. now, when i change
the selectedIndex of combobox1, it automatically changes the selectedIndex
of combobox2.
does this mean, that the combobox selects the item on the base of some kind
of a pointer on the dataview? if yes, is there a class inside the framework,
which i can use to change this pointer on the dataview myself?
thanx for any hint.
jazper 4 2944
Hi,
"Jazper Manto" <ej*****@hotmail.com> wrote in message
news:uW**************@TK2MSFTNGP09.phx.gbl... hi
i bounded the same dataview to 2 different comboboxes. now, when i change the selectedIndex of combobox1, it automatically changes the selectedIndex of combobox2. does this mean, that the combobox selects the item on the base of some kind of a pointer on the dataview?
Well, there is a little more to it. The DataView itself doesn't mantain the
position, but a CurrencyManager does. A CurrencyManager is unique for each
(bound) DataSource/DataMember within a BindingContext. By default a
BindingContext is shared between a Form and all of its controls.
If you want independent navigating with the same DataSource/DataMember, you
need to assign a new BindingContext to the different controls as this would
result in a different CurrencyManager (for the same DataSource/DataMember).
if yes, is there a class inside the framework, which i can use to change this pointer on the dataview myself?
The general way the get a CurrencyManager would be:
CurrencyManager cm = (CurrencyManager)BindingContext[dataSource,
dataMember];
But if the DataMember wasn't used for binding then it can be omitted, eg. :
CurrencyManager cm = (CurrencyManager)BindingContext[myDataView];
Lookup the CurrencyManager class, it has a few properties, like Position
which you can read and change.
HTH,
Greetings thanx for any hint. jazper
> Well, there is a little more to it. The DataView itself doesn't mantain
the position, but a CurrencyManager does. A CurrencyManager is unique for
each (bound) DataSource/DataMember within a BindingContext. By default a BindingContext is shared between a Form and all of its controls.
perfect answer. thank you.
you said the BindingContext is shared between a Form and all of its
controls... hmmm. i have another problem which has been explained while i
read your statement. i have a winform with a panel-object in it. this panel
contains bounded comboboxes. as soon as i grap this panel and add it to
another controlcollection of another form it gets another CurrencyManager.
can i avoid this problem or set back the CurrencyManager in some way?
thanx jazper
Hi,
[Inline]
"Jazper Manto" <ej*****@hotmail.com> wrote in message
news:uG**************@TK2MSFTNGP14.phx.gbl... Well, there is a little more to it. The DataView itself doesn't mantain the position, but a CurrencyManager does. A CurrencyManager is unique for each (bound) DataSource/DataMember within a BindingContext. By default a BindingContext is shared between a Form and all of its controls.
perfect answer. thank you. you said the BindingContext is shared between a Form and all of its controls...
Yes, to explain this a little more, the Form creates a BindingContext, then
when you bind to any Control it needs a BindingContext but if none have been
set to that Control it will use the BindingContext of the parent.
On the other hand, if a BindingContext has been explicitly set to a Control
it will no longer use its parents one, not even when you move the Control
between forms.
hmmm. i have another problem which has been explained while i read your statement. i have a winform with a panel-object in it. this panel contains bounded comboboxes. as soon as i grap this panel and add it to another controlcollection of another form it gets another CurrencyManager.
can i avoid this problem or set back the CurrencyManager in some way?
Yes, by keeping the same BindingContext.
In Form load (preferably before binding, but it's not mandatory) explicitly
set the panel's BindingContext. Like explained above, once you have set it
explicitly it won't change when you add the panel to another Form.
You still have a choice between just using the parent's BindingContext or
creating a new one, eg:
panel1.BindingContext = new BindingContext();
---or---
panel1.BindingContext = this.BindingContext();
The latter may look useless but it isn't because here you're setting it
explicitly which makes the difference.
HTH,
Greetings thanx jazper
hi bart
again thank you for your explanations. Yes, to explain this a little more, the Form creates a BindingContext,
then when you bind to any Control it needs a BindingContext but if none have
been set to that Control it will use the BindingContext of the parent.
On the other hand, if a BindingContext has been explicitly set to a
Control it will no longer use its parents one, not even when you move the Control between forms.
perfect. excactly the solution i needed. :-)
cheers, jazper This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: DraguVaso |
last post by:
Hi,
I have 2 comboboxes, both bound to a different DataView, but thoe DataViews
are bound to 1 DataTable in 1 DataSet.
Like this:
Dim dvwList2 As New DataView
dvwList2 =...
|
by: Alpha |
last post by:
I have a listbox with datasource from a dataview. When a user selects a
different item in a combobox then I need to refresh the listbox to the
appropriate listing based on that combobox's selected...
|
by: Alpha |
last post by:
I have a window application. On one of the form, there is a listbox and a
few combox. The lstSchItem has a dataview as a datasource. The comboxes are
bind to its selected value but through the...
|
by: Greg Linwood |
last post by:
I am wondering what the best approach to binding XML data to an asp:Table
from the Page_Load event in a code behind module?
I'm using VB.Net and initially approached this by adding a table to the...
|
by: Kenneth |
last post by:
Hi,
I want to make sure I got the easiest way on how to bind a grid's datasource to a datatable.
I've made an in-memory datatable
Dim dtTotal As DataTable
Dim drow As DataRow
dtTotal = New...
|
by: A_PK |
last post by:
I have problem databinding the DataGrid with DataView/DataSet after the
filter...
I create the following proceudre in order for user to filter as many as they
want, but the following code is only...
|
by: Niki |
last post by:
I'm using findrows to extract specific rows from a dataview, and then want to
bind to them.
I'd assumed that you bound to the array result as you would to the the
dataview, but the system can't...
|
by: Camel |
last post by:
Hi,
I'm just learning the new databinding paradigm in ASP.NET 2 and I have
a question. What if I want to use 1 SqlDataSource for 2 comboboxes?
What I want is a master/detail relationship...
|
by: Randy |
last post by:
I have a routine that creates a series of comboboxes, each of which is
bound to a common dataview. Everything used to work fine, but now,
when I change the value of any of the comboboxes, the...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
| |