⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 toolbardropdownlist.cs

📁 浏览器端看到树型目录结构,用户可以完整地看到像windows资源管理器一样的效果
💻 CS
📖 第 1 页 / 共 3 页
字号:
                ViewState["AutoPostBack"] = value;
                _List.AutoPostBack = value;
            }
        }

        /// <summary>
        /// Gets or sets the lowest ordinal index of the selected items in the list.
        /// </summary>
        [
        Category("Behavior"),
        DefaultValue(0),
        DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden),
        Browsable(false),
        ]
        public virtual int SelectedIndex
        {
            get { return _List.SelectedIndex; }
            set { _List.SelectedIndex = value; }
        }

        /// <summary>
        /// Gets the collection of items in the list control.
        /// </summary>
        [
        Category("Data"),
        DefaultValue(null),
        MergableProperty(false),
        PersistenceMode(PersistenceMode.InnerDefaultProperty),
        ResDescription("DropDownItems"),
        ]
        public virtual ListItemCollection Items
        {
            get { return _List.Items; }
        }

        /// <summary>
        /// Gets the selected item with the lowest index in the list control.
        /// </summary>
        [
        Category("Behavior"),
        Browsable(false),
        DefaultValue(null),
        DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)
        ]
        public virtual ListItem SelectedItem
        {
            get { return _List.SelectedItem; }
        }

        /// <summary>
        /// Clears the selection.
        /// </summary>
        public virtual void ClearSelection()
        {
            _List.ClearSelection();
        }

        /// <summary>
        /// Gets or sets the keyboard shortcut key (AccessKey) for setting focus to the item.
        /// </summary>
        public override string AccessKey
        {
            get { return _List.AccessKey; }
            set { base.AccessKey = _List.AccessKey = value; }
        }

        /// <summary>
        /// Gets or sets a value indicating whether the textbox is enabled.
        /// </summary>
        public override bool Enabled
        {
            get { return _List.Enabled; }
            set { base.Enabled = _List.Enabled = value; }
        }

        /// <summary>
        /// Gets or sets the tab index of the item.
        /// </summary>
        public override short TabIndex
        {
            get { return _List.TabIndex; }
            set { base.TabIndex = _List.TabIndex = value; }
        }

        /// <summary>
        /// Gets or sets the tool tip for the item to be displayed when the mouse cursor is over the control.
        /// </summary>
        [
        Bindable(false),
        Browsable(false),
        DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden),
        EditorBrowsableAttribute(EditorBrowsableState.Never)
        ]
        public override string ToolTip
        {
            get { return _List.ToolTip; }
            set { base.ToolTip = _List.ToolTip = value; }
        }

        /// <summary>
        /// Gets or sets the data source that populates the items of the list control.
        /// </summary>
        [
        Bindable(true),
        Category("Data"),
        DefaultValue(null),
        DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden),
        ]
        public virtual object DataSource
        {
            get { return _List.DataSource; }
            set { _List.DataSource = value; }
        }

        /// <summary>
        /// Gets or sets the specific table in the DataSource to bind to the control.
        /// </summary>
        [
        DefaultValue(""),
        Category("Data"),
        ResDescription("DropDownDataMember"),
        ]
        public virtual string DataMember
        {
            get { return _List.DataMember; }
            set { _List.DataMember = value; }
        }

        /// <summary>
        /// Gets or sets the formatting string used to control how data bound to the list control is displayed.
        /// </summary>
        [
        Category("Data"),
        DefaultValue(""),
        ResDescription("DropDownDataTextFormatString"),
        ]
        public virtual string DataTextFormatString
        {
            get { return _List.DataTextFormatString; }
            set { _List.DataTextFormatString = value; }
        }

        /// <summary>
        /// Gets or sets the field of the data source that provides the text content of the list items.
        /// </summary>
        [
        Category("Data"),
        DefaultValue(""),
        ResDescription("DropDownDataTextField"),
        ]
        public virtual string DataTextField
        {
            get { return _List.DataTextField; }
            set { _List.DataTextField = value; }
        }

        /// <summary>
        /// Gets or sets the field of the data source that provides the value of each list item.
        /// </summary>
        [
        Category("Data"),
        DefaultValue(""),
        ResDescription("DropDownDataValueField"),
        ]
        public virtual string DataValueField
        {
            get { return _List.DataValueField; }
            set { _List.DataValueField = value; }
        }

        /// <summary>
        /// Causes data binding to occur on the invoked control and all of its child controls.
        /// </summary>
        public void DataBind()
        {
            _List.DataBind();
        }

        /// <summary>
        /// The ID of the hidden helper.
        /// </summary>
        internal string HelperID
        {
            get
            {
                if (_HelperID == null)
                {
                    Toolbar parent = ParentToolbar;
                    if (parent == null)
                    {
                        return String.Empty;
                    }

                    _HelperID = "__" + parent.ClientID + "_" + Index.ToString() + "__";
                }

                return _HelperID;
            }
        }

        /// <summary>
        /// Processes the new data.
        /// </summary>
        /// <param name="data">The new selected value.</param>
        /// <returns>Returns true if there was a change.</returns>
        private bool ProcessData(string data)
        {
            try
            {
                ListItem item = Items.FindByValue(data);
                if (item != null)
                {
                    int index = Items.IndexOf(item);
                    if (index != SelectedIndex)
                    {
                        SelectedIndex = index;
                        return true;
                    }
                }
            }
            catch
            {
                // If there is an error, ignore it and don't set the data
            }
            
            return false;
        }

        /// <summary>
        /// Loads postback data into the control.
        /// </summary>
        /// <param name="postDataKey">The key identifier for the control.</param>
        /// <param name="postCollection">The collection of all incoming name values.</param>
        /// <returns>true if the server control's state changes as a result of the post back; otherwise false.</returns>
        bool IPostBackDataHandler.LoadPostData(string postDataKey, NameValueCollection postCollection)
        {
            string szData = postCollection[HelperID];
            if (szData != null)
            {
                return ProcessData(szData);
            }

            return false;
        }

        /// <summary>
        /// Signals the server control object to notify the ASP.NET application that the state of the control has changed.
        /// </summary>
        void IPostBackDataHandler.RaisePostDataChangedEvent()
        {
            OnSelectedIndexChanged(this, EventArgs.Empty);
        }

        /// <summary>
        /// Initializes postback data fields. Should be called from OnPreRender.
        /// </summary>
        /// <param name="isUpLevel"></param>
        internal void SetupHiddenHelper(bool isUpLevel)
        {
            _List.ID = HelperID;

            Toolbar parent = ParentToolbar;
            if (isUpLevel && (parent != null) && (parent.Page != null) && (_List.SelectedItem != null))
            {
                parent.Page.RegisterHiddenField(HelperID, _List.SelectedItem.Value);
            }
        }

        /// <summary>
        /// Initializes the selected index.
        /// </summary>
        private void ResolveSelectedIndex()
        {
            try
            {
                int index = SelectedIndex;
                if ((index >= 0) && (index < Items.Count))
                {
                    _List.SelectedIndex = index;
                }
            }
            catch
            {
                // Ignore errors
            }
        }

        /// <summary>
        /// The product of merging local and global styles.
        /// </summary>
        protected override CssCollection CurrentStyle
        {
            get
            {
                CssCollection style = base.CurrentStyle;

                // Due to the order in which we want to inherit fonts,
                // we need to make DefaultStyle override Style override Parent.DefaultStyle
                if (style["font-family"] != null)
                {
                    if ((DefaultStyle["font-family"] == null) && (Font.Names.Length > 0))
                    {
                        style.Remove("font-family");
                    }
                }

                if (style["font-size"] != null)
                {
                    if ((DefaultStyle["font-size"] == null) && (!Font.Size.IsEmpty))
                    {
                        style.Remove("font-size");
                    }
                }

                if (style["font-weight"] != null)
                {
                    if ((DefaultStyle["font-weight"] == null) && Font.Bold)
                    {
                        style.Remove("font-weight");
                    }
                }

                if (style["font-style"] != null)
                {
                    if ((DefaultStyle["font-style"] == null) && Font.Italic)
                    {
                        style.Remove("font-style");
                    }
                }

                return style;
            }
        }

        /// <summary>
        /// The uplevel ToolbarTag ID for the toolbar item.
        /// </summary>
        protected override string UpLevelTag
        {
            get { return Toolbar.DropDownListTagName; }
        }

        /// <summary>
        /// Returns true if the child has uplevel content.
        /// </summary>
        protected override bool HasUpLevelContent
        {
            get { return true; }
        }

        /// <summary>
        /// Renders ToolbarItem attributes.
        /// </summary>
        /// <param name="writer">The HtmlTextWriter to receive markup.</param>
        protected override void WriteItemAttributes(HtmlTextWriter writer)
        {
            base.WriteItemAttributes(writer);

            string css = CssClass;
            if (css.Length > 0)
            {
                writer.WriteAttribute("class", css);
            }

            string style = String.Empty;

            Color color = ForeColor;
            if (!color.IsEmpty)
            {
                style += "color:" + ColorTranslator.ToHtml(color) + ";";

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -