/// <include file='doc\DataGridGeneralPage.uex' path='docs/doc[@for="DataGridGeneralPage.LoadDataSourceFields"]/*' />
        /// <devdoc>
        /// </devdoc>
        private void LoadDataSourceFields()
        {
            EnterLoadingMode();

            dataKeyFieldCombo.SelectedIndex = -1;
            dataKeyFieldCombo.Items.Clear();
            dataKeyFieldCombo.EnsureNotSetItem();

            if (currentDataSource != null)
            {
                PropertyDescriptorCollection fields = currentDataSource.Fields;

                if (fields != null)
                {
                    IEnumerator fieldEnum = fields.GetEnumerator();
                    while (fieldEnum.MoveNext())
                    {
                        PropertyDescriptor fieldDesc = (PropertyDescriptor)fieldEnum.Current;

                        if (BaseDataList.IsBindableType(fieldDesc.PropertyType))
                        {
                            dataKeyFieldCombo.AddItem(fieldDesc.Name);
                        }
                    }
                }
            }

            ExitLoadingMode();
        }
Exemplo n.º 2
0
        /// <summary>
        /// </summary>
        private void LoadDataSourceFields()
        {
            using (new LoadingModeResource(this))
            {
                _dataTextFieldCombo.SelectedIndex = -1;
                _dataTextFieldCombo.Items.Clear();
                _dataTextFieldCombo.EnsureNotSetItem();

                _dataValueFieldCombo.SelectedIndex = -1;
                _dataValueFieldCombo.Items.Clear();
                _dataValueFieldCombo.EnsureNotSetItem();

                if (_currentDataSource != null)
                {
                    PropertyDescriptorCollection fields = _currentDataSource.Fields;

                    if (fields != null)
                    {
                        IEnumerator fieldEnum = fields.GetEnumerator();
                        while (fieldEnum.MoveNext())
                        {
                            PropertyDescriptor fieldDesc = (PropertyDescriptor)fieldEnum.Current;

                            if (BaseDataList.IsBindableType(fieldDesc.PropertyType))
                            {
                                _dataTextFieldCombo.AddItem(fieldDesc.Name);
                                _dataValueFieldCombo.AddItem(fieldDesc.Name);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
        private void Test(Type CtlType)
        {
            Type type1;
            bool flag1;

            try
            {
                this.GHTSubTestBegin("BaseDataList_" + CtlType.Name + "_IsBindableType1");
                Type[] typeArray1 = this.marrBindaleType;
                for (int num1 = 0; num1 < typeArray1.Length; num1++)
                {
                    type1 = typeArray1[num1];
                    flag1 = BaseDataList.IsBindableType(type1);
                    this.GHTSubTestAddResult(type1.ToString() + " is bindable = " + flag1.ToString());
                }
            }
            catch (Exception exception4)
            {
                this.GHTSubTestUnexpectedExceptionCaught(exception4);
            }
            this.GHTSubTestEnd();
            try
            {
                this.GHTSubTestBegin("BaseDataList_" + CtlType.Name + "_IsBindableType2");
                type1 = null;
                flag1 = BaseDataList.IsBindableType(null);
                this.GHTSubTestAddResult("Nothing is bindable = " + flag1.ToString());
                this.GHTSubTestExpectedExceptionNotCaught("NullReferenceException");
            }
            catch (NullReferenceException exception5)
            {
                this.GHTSubTestExpectedExceptionCaught(exception5);
                return;
            }
            catch (Exception exception6)
            {
                this.GHTSubTestUnexpectedExceptionCaught(exception6);
                return;
            }
        }
Exemplo n.º 4
0
 public void IsBindableType()
 {
     // documented
     Assert.IsTrue(BaseDataList.IsBindableType(typeof(bool)), "bool");
     Assert.IsTrue(BaseDataList.IsBindableType(typeof(byte)), "byte");
     Assert.IsTrue(BaseDataList.IsBindableType(typeof(sbyte)), "sbyte");
     Assert.IsTrue(BaseDataList.IsBindableType(typeof(short)), "short");
     Assert.IsTrue(BaseDataList.IsBindableType(typeof(ushort)), "ushort");
     Assert.IsTrue(BaseDataList.IsBindableType(typeof(int)), "int");
     Assert.IsTrue(BaseDataList.IsBindableType(typeof(uint)), "uint");
     Assert.IsTrue(BaseDataList.IsBindableType(typeof(long)), "long");
     Assert.IsTrue(BaseDataList.IsBindableType(typeof(ulong)), "ulong");
     Assert.IsTrue(BaseDataList.IsBindableType(typeof(char)), "char");
     Assert.IsTrue(BaseDataList.IsBindableType(typeof(double)), "double");
     Assert.IsTrue(BaseDataList.IsBindableType(typeof(float)), "float");
     Assert.IsTrue(BaseDataList.IsBindableType(typeof(DateTime)), "DateTime");
     Assert.IsTrue(BaseDataList.IsBindableType(typeof(decimal)), "decimal");
     Assert.IsTrue(BaseDataList.IsBindableType(typeof(string)), "string");
     // and others (from TypeCode)
     Assert.IsFalse(BaseDataList.IsBindableType(typeof(object)), "object");
     Assert.IsFalse(BaseDataList.IsBindableType(typeof(DBNull)), "DBNull");
     // and junk
     Assert.IsFalse(BaseDataList.IsBindableType(this.GetType()), "this");
 }
Exemplo n.º 5
0
 public void IsBindableType_Null()
 {
     BaseDataList.IsBindableType(null);
 }