public virtual CurrencyManager GetRelatedCurrencyManager(string dataMember)
        {
            if (dataMember == null || dataMember.Length == 0)
                return currency_manager;

            if (related_currency_managers.ContainsKey (dataMember))
                return related_currency_managers [dataMember];

            // FIXME - Why passing invalid dataMembers containing a . return
            // a null value?
            if (dataMember.IndexOf ('.') != -1)
                return null;

            BindingSource source = new BindingSource (this, dataMember);
            related_currency_managers [dataMember] = source.CurrencyManager;

            return source.CurrencyManager;
        }
Beispiel #2
0
        protected override void OnShown()
        {
            base.OnShown ();

            BindingContext = new BindingContext ();

            customers = new List<Customer>() { new Customer() { CompanyID = 1, CompanyName = "Acme Workshop" },
                                                        new Customer() { CompanyID = 2, CompanyName = "Sirius Tech"} };
            formscombobox1.DataSource = customers;
            formscombobox1.DisplayMember = "CompanyName";
            formscombobox1.ValueMember = "CompanyID";

            formslabel1.DataBindings.Add("Text", customers, "CompanyId");

            customers2 = new NotifiedBindingList<Customer>() { new Customer() { CompanyID = 1, CompanyName = "Acme Workshop" },
                                                    new Customer() { CompanyID = 2, CompanyName = "Sirius Tech"} };
            bsrcCustomers = new BindingSource() { DataSource = customers2 };

            formscombobox2.DataSource = bsrcCustomers;
            formscombobox2.DisplayMember = "CompanyName";
            formscombobox2.ValueMember = "CompanyID";

            formslabel2.DataBindings.Add("Text", bsrcCustomers, "CompanyId");

            customers3 = new NotifiedBindingList<Customer>() { new Customer() { CompanyID = 1, CompanyName = "Acme Workshop" },
                                                       new Customer() { CompanyID = 2, CompanyName = "Sirius Tech"} };

            formscomboboxentry1.DataSource = customers3;
            formscomboboxentry1.DisplayMember = "CompanyName";
            formscomboboxentry1.ValueMember = "CompanyID";
            formscomboboxentry1.DataBindings.Add("Text", customers3, "CompanyName", true, DataSourceUpdateMode.OnPropertyChanged);

            formslabel3.DataBindings.Add("Text", customers3, "CompanyId");
            formslabel4.DataBindings.Add("Text", customers3, "CompanyName");

            var bsrcCities = new BindingSource() { DataSource = new NotifiedBindingList<string> { "Warszawa", "Krakow"}};
            //formscombobox3.DataSource = bsrcCities;

            City city = new City ();
            //city.CityName = "Krakow";
            formscombobox3.DataSource = bsrcCities;
            formscombobox3.DataBindings.Add ("SelectedItem", city, "CityName", false, DataSourceUpdateMode.OnPropertyChanged);
            formscombobox3.DataBindings[0].WriteValue();
            labelCityName.DataBindings.Add ("Text", city, "CityName");

            //			formscombobox3.DataSource = bsrcCities;

            city.CityType = CityTypes.City;
            comboboxEnum.DataSource = Enum.GetValues (typeof(CityTypes));
            comboboxEnum.DataBindings.Add ("SelectedItem", city, "CityType", false, DataSourceUpdateMode.OnPropertyChanged);
            //			comboboxEnum.DataSource = Enum.GetValues (typeof(CityTypes));

            labelEnum.DataBindings.Add ("Text", city, "CityType");

            City city2 = new City ();
            comboboxEnum2.DataSource = Enum.GetValues (typeof(CityTypes));
            comboboxEnum2.DataBindings.Add ("SelectedItem", city2, "CityType", false, DataSourceUpdateMode.OnPropertyChanged);
            comboboxEnum2.DataBindings [0].WriteValue ();
            labelEnum2.DataBindings.Add ("Text", city2, "CityType");
        }