当前位置: 首页>>代码示例>>C#>>正文


C# ComboBoxEx.CreateGraphics方法代码示例

本文整理汇总了C#中ComboBoxEx.CreateGraphics方法的典型用法代码示例。如果您正苦于以下问题:C# ComboBoxEx.CreateGraphics方法的具体用法?C# ComboBoxEx.CreateGraphics怎么用?C# ComboBoxEx.CreateGraphics使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ComboBoxEx的用法示例。


在下文中一共展示了ComboBoxEx.CreateGraphics方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: createComboBox

        private Control createComboBox(Question q)
        {
            FlowLayoutPanel pnlInner = new FlowLayoutPanel();
            pnlInner.FlowDirection = FlowDirection.LeftToRight;

            int innerPanelLength = 0;

            //如果 Question 有 Label ,則要在前面加上 Label
            if (q.HasLabel)
            {
                Label lbl = this.createLabel(q.GetQuestionLabel());
                pnlInner.Controls.Add(lbl);
                innerPanelLength += lbl.Width + 6;
            }

            //create combobox
            ComboBoxEx cbo = new ComboBoxEx();
            cbo.Enabled = false;
            cbo.Name = q.GetQuestionName();
            cbo.DropDownStyle = ComboBoxStyle.DropDown;
            cbo.Tag = q;
            cbo.TextChanged += new EventHandler(txt_TextChanged); ;
            Graphics g = cbo.CreateGraphics();
            SizeF maxSize = new SizeF();

            Font f = this.pnlQGroup.Font;
            foreach (QuestionListItem item in this.questionGroup.GetListItems())
            {
                int index = cbo.Items.Add(item.GetLabel());
                if (item.Selected)
                    cbo.SelectedText = item.GetLabel();

                SizeF theSize = g.MeasureString(item.GetLabel(), f);
                if (theSize.Width > maxSize.Width)
                    maxSize = theSize;
            }

            cbo.Width = (int)maxSize.Width + 25;
            pnlInner.Controls.Add(cbo);
            this.allQControls.Add(cbo.Name, cbo);

            pnlInner.Width = innerPanelLength + cbo.Width + 6;
            pnlInner.Height = cbo.Height + 6;

            //adjust height
            int periodCount = 4;
            this.contentPanel.Height = 6 + 20 * ((this.questionGroup.GetQuestions().Count % periodCount == 0) ? (this.questionGroup.GetQuestions().Count / periodCount + 1) : (this.questionGroup.GetQuestions().Count / periodCount + 2));

            this.pnlQGroup.Height = this.contentPanel.Height + 6;
            return pnlInner;
        }
开发者ID:ChunTaiChen,项目名称:Counsel_System,代码行数:51,代码来源:QGUIMaker.cs


注:本文中的ComboBoxEx.CreateGraphics方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。