• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# ComboBox类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ComboBox的典型用法代码示例。如果您正苦于以下问题:C# ComboBox类的具体用法?C# ComboBox怎么用?C# ComboBox使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ComboBox类属于命名空间,在下文中一共展示了ComboBox类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Create

    public override Widget Create(object caller)
    {
        HBox box = new HBox();

        PropertiesView propview = (PropertiesView)caller;

        // Add the names of the sectors to a list
        sectorNames = new List<String>(propview.application.CurrentLevel.Sectors.Count);
        foreach(Sector sector in propview.application.CurrentLevel.Sectors) {
            sectorNames.Add(sector.Name);
        }

        // Populate a combo box with the sector names
        comboBox = new ComboBox(sectorNames.ToArray());

        OnFieldChanged(Field); //same code for initialization

        comboBox.Changed += OnComboBoxChanged;
        box.PackStart(comboBox, true, true, 0);

        box.Name = Field.Name;

        CreateToolTip(caller, comboBox);

        return box;
    }
开发者ID:Karkus476,项目名称:supertux-editor,代码行数:26,代码来源:ChooseSectorWidget.cs


示例2: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    { 
        ComboBox1 = new ComboBox();
        ComboBox1.ID = "ComboBox1";
        ComboBox1.Width = Unit.Pixel(250);
        ComboBox1.EmptyText = "Select a customer ...";
        ComboBox1.DataSourceID = "sds1"; 
        ComboBox1.DataTextField = "CompanyName";
        ComboBox1.DataValueField = "CustomerID";
        ComboBox1.FolderStyle = "styles/black_glass";

        ComboBoxContainer1.Controls.Add(ComboBox1);

        ComboBox2 = new ComboBox();
        ComboBox2.ID = "ComboBox2";
        ComboBox2.Width = Unit.Pixel(250);
        ComboBox2.EmptyText = "Select a customer ...";
        ComboBox2.DataSourceID = "sds1";
        ComboBox2.DataTextField = "CompanyName";
        ComboBox2.DataValueField = "CustomerID";
        ComboBox2.FolderStyle = "_";

        ComboBoxContainer2.Controls.Add(ComboBox2);

        ComboBox3 = new ComboBox();
        ComboBox3.ID = "ComboBox3";
        ComboBox3.Width = Unit.Pixel(250);
        ComboBox3.EmptyText = "Select a customer ...";
        ComboBox3.DataSourceID = "sds1";
        ComboBox3.DataTextField = "CompanyName";
        ComboBox3.DataValueField = "CustomerID";
        ComboBox3.FolderStyle = "_";
  
        ComboBoxContainer3.Controls.Add(ComboBox3);
    }
开发者ID:veraveramanolo,项目名称:power-show,代码行数:35,代码来源:cs_different_styles.aspx.cs


示例3: OnListItemUnselected

 void OnListItemUnselected(ComboBox.ComboItem unselectedItem)
 {
     if (selectedHost == (HostData)unselectedItem.value)
     {
         selectedHost = null;
     }
 }
开发者ID:niguerrac,项目名称:UnityUI,代码行数:7,代码来源:MasterServerInterface.cs


示例4: Calendar1_DayRender

    protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
    {
        // DateTime dt=Calendar1.SelectedDate;
        // Response.Write(dt.ToString());
        //if (e.Day.Date == dt)
        //{
        //ComboBox a1 = new ComboBox();

        //a1.ID = 'a' + i.ToString();
        //a1.AutoCompleteMode = ComboBoxAutoCompleteMode.Suggest;
        //a1.DropDownStyle = ComboBoxStyle.DropDownList;
        //i++;
        //        e.Cell.Controls.Add(tb);
        //    }
        //Response.Write(e.Day.Date.ToString());
        DateTime dt = Calendar1.SelectedDate;
        if (e.Day.Date == dt)
        {
            ArrayList al=new ArrayList();
            al.Add(1);
            al.Add(2);
            al.Add(3);
            ComboBox cb = new ComboBox();
            cb.DataSource = al;
            cb.ID = "a";
            cb.AutoCompleteMode = ComboBoxAutoCompleteMode.Suggest;
            cb.DropDownStyle = ComboBoxStyle.DropDownList;
            e.Cell.Controls.Add(cb);
        }
    }
开发者ID:fping1245,项目名称:test20121224,代码行数:30,代码来源:arrcls.aspx.cs


示例5: Create

    public override Widget Create(object caller)
    {
        HBox box = new HBox();

        PropertiesView propview = (PropertiesView)caller;

        // Add the names of the sectors to a list
        List<String> sectorNames = new List<String>(propview.application.CurrentLevel.Sectors.Count);
        foreach(Sector sector in propview.application.CurrentLevel.Sectors) {
            sectorNames.Add(sector.Name);
        }

        // Populate a combo box with the sector names
        comboBox = new ComboBox(sectorNames.ToArray());

        // Get the index of the current value from the original list
        // due to limitations in ComboBox
        string val = (string)field.GetValue(Object);
        if (val != null)
            comboBox.Active = sectorNames.IndexOf(val);

        comboBox.Changed += OnComboBoxChanged;
        box.PackStart(comboBox, true, true, 0);

        box.Name = field.Name;

        CreateToolTip(caller, comboBox);

        return box;
    }
开发者ID:BackupTheBerlios,项目名称:supertux-svn,代码行数:30,代码来源:ChooseSectorWidget.cs


示例6: Start

    private void Start()
    {
        //This is the list that we want to show up in our combobox options
        comboBoxList = new GUIContent[12];
        comboBoxList[0] = new GUIContent("First Level Test 1");
        comboBoxList[1] = new GUIContent("First Level Test 2");
        comboBoxList[2] = new GUIContent("First Level Test 3");
        comboBoxList[3] = new GUIContent("Second Level Test 1");
        comboBoxList[4] = new GUIContent("Second Level Test 2");
        comboBoxList[5] = new GUIContent("Second Level Test 3");
        comboBoxList[6] = new GUIContent("Third Level Test 1");
        comboBoxList[7] = new GUIContent("Third Level Test 2");
        comboBoxList[8] = new GUIContent("Third Level Test 3");
        comboBoxList[9] = new GUIContent("Fourth Level Test 1");
        comboBoxList[10] = new GUIContent("Fourth Level Test 2");
        comboBoxList[11] = new GUIContent("Fourth Level Test 3");

        listStyle.normal.textColor = Color.white;
        listStyle.onHover.background =
        listStyle.hover.background = new Texture2D(2, 2);
        listStyle.padding.left =
        listStyle.padding.right =
        listStyle.padding.top =
        listStyle.padding.bottom = 4;

        comboBoxControl = new ComboBox(new Rect(Screen.width/2 -130, Screen.height/2 - 25, 150, 20), comboBoxList[0], comboBoxList, "button", "box", listStyle);
    }
开发者ID:relinko01,项目名称:Dressage,代码行数:27,代码来源:TestSelection.cs


示例7: DataGridComboBoxColumn

 /// <summary>
 /// The only creator ;)
 /// </summary>
 /// <param name="colName">The name of the column</param>
 /// <param name="dataSource">The datasource that contains the lookup table</param>
 /// <param name="displayMember">The member of the lookuptable to display</param>
 /// <param name="valueMember">The member of the lookuptable with the value</param>
 /// <param name="dataGrid">The datagrid parent of this column</param>
 public DataGridComboBoxColumn(string colName, DataTable dataSource, string displayMember, string valueMember, DataGrid dataGrid)
 {
     _comboBox = new ComboBox();
     _comboBox.Visible = false;
     _comboBox.DataSource = dataSource;
     _dataTable = dataSource;
     _comboBox.DisplayMember = displayMember;
     _displayMember = displayMember;
     _valueMember = valueMember;
     _comboBox.ValueMember = valueMember;
     _comboBox.DropDownStyle = ComboBoxStyle.DropDownList;
     Graphics _graphicsContext = dataGrid.CreateGraphics();
     float _widest = 0;
     SizeF _stringSize = new SizeF(0, 0);
     foreach (DataRow dr in dataSource.Rows)
     {
         _stringSize = _graphicsContext.MeasureString(dr[displayMember].ToString(), dataGrid.Font);
         if (_stringSize.Width > _widest)
         {
             _widest = _stringSize.Width;
         }
     }
     _comboBox.DropDownWidth = (int)Math.Ceiling(_widest);
     this.Width = _comboBox.DropDownWidth + 25; // Add the space for the dropdown arrow
     this.MappingName = colName;
     this.HeaderText = colName;
     dataGrid.Controls.Add(_comboBox);
 }
开发者ID:hayrettinbebek,项目名称:e-cafe,代码行数:36,代码来源:CellStyles.cs


示例8: Start

    void Start()
    {
        // Set up our fullscreen toggle button
        if (GameObject.Find("FullscreenToggle") != null) {
            fullscreen = GameObject.Find("FullscreenToggle").GetComponent<Toggle>();
            if (Screen.fullScreen) fullscreen.isOn = true;
            else fullscreen.isOn = false;
        }

        // Set up our resolution dropdown box
        if (GameObject.Find("ResolutionList") != null) {
            resolutions = GameObject.Find("ResolutionList").GetComponent<ComboBox>();
            ComboBoxItem[] items = new ComboBoxItem[Screen.resolutions.Length];
            int counter = 0;

            Resolution[] res = Screen.resolutions;
            foreach (Resolution r in res) {
                items[counter] = new ComboBoxItem(r);
                counter++;
            }

            resolutions.Items = items;
            resolutions.ItemsToDisplay = 5;

            Resolution tmpRes = Screen.currentResolution;
            foreach (Resolution r in Screen.resolutions) {
                if (Screen.width == r.width && Screen.height == r.height) {
                    tmpRes = r;
                    break;
                }
            }
            resolutions.SelectedIndex = System.Array.IndexOf(Screen.resolutions, tmpRes);
        }
    }
开发者ID:parkersprouse,项目名称:Spectrum,代码行数:34,代码来源:OptionsMenuHandler.cs


示例9: GUI_Proof

	// Constructor. It builds our application. It also calls its parent constructor through the base() keyword. 
	public GUI_Proof() : base("Example GTK# App"){
		// Sets a default size for our window. 
		this.SetDefaultSize(700, 500);
		// Centers the window on the screen. 
		this.SetPosition(WindowPosition.Center);
		// Sets an icon from the current directory
		//SetIconFromFile("web.png");
		// WIDGETS------------------------------------------
		// Containers
		Fixed fix = new Fixed();
		// Labels
		result.Text = "Pick a datatype";
		// ComboBox
		ComboBox cb = new ComboBox(dataTypes);
		// WIDGET's SETTINGS--------------------------------
		fix.Put(cb, 50, 30);
		fix.Put(result, 200, 30);
		// ADDS---------------------------------------------
		fix.Add(cb);
		fix.Add(result);
		this.Add(fix);
		// EVENT's ATTACH
		/* We plug a delegate to the DeleteEvent. This event is triggered, 
		 * when we click on the close button in the titlebar. Or press Alt+F4.
		 * Our delegate quits the application for good.  */
		//DeleteEvent += delegate { Application.Quit(); };
		/* This is another way, how we can plug an event handler to an event.
		 * It is just a bit more verbose. */
		this.DeleteEvent += new DeleteEventHandler(OnDelete);
		cb.Changed += OnChanged;
		// Now we show the window. The window is not visible, until we call the Show() method. 
		//Show();
		// This will work for all widgets and panels in the application
		this.ShowAll();
	}
开发者ID:JCarlosGMarias,项目名称:CSWarlords,代码行数:36,代码来源:GUI_Proof.cs


示例10: ComboBoxEditorBase

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="label"></param>
        /// <param name="property"></param>
        public ComboBoxEditorBase(PropertyLabel label, PropertyItem property)
            : base(property)
        {
            currentValue = property.Value;
              property.PropertyChanged += property_PropertyChanged;
              property.ValueError += property_ValueError;

              cbo = new ComboBox
              {
            Visibility = Visibility.Collapsed,
            Margin = new Thickness(0),
            VerticalAlignment = VerticalAlignment.Center,
            HorizontalAlignment = HorizontalAlignment.Stretch
              };

              cbo.DropDownOpened += cbo_DropDownOpened;
              cbo.LostFocus += cbo_LostFocus;

              this.InitializeCombo();

              pnl = new StackPanel();
              pnl.Children.Add(cbo);

              this.ShowTextBox();

              this.Content = pnl;
        }
开发者ID:DenisVuyka,项目名称:SPG,代码行数:32,代码来源:ComboBoxEditorBase.cs


示例11: AddThemeListTo

 /// <summary>
 /// Adds the list of themes to the specified combobox reference.
 /// </summary>
 /// <param name="comboBox"></param>
 public static void AddThemeListTo(ref ComboBox comboBox)
 {
     foreach (var theme in ThemeList)
     {
         comboBox.AddItem(theme.ToString(), ((int)theme).ToString());
     }
 }
开发者ID:omazlov,项目名称:Ext.NET.Examples,代码行数:11,代码来源:ThemeListHandler.cs


示例12: Form1

    public Form1()
    {
        this.Width = 335;
        this.Height = 380;
        this.Text = "ConvertDB";

        txtFileName = new TextBox {
          Location = new Point(10, 10),
          Size = new Size(270, 30),
          Text = "Please Input a target file name",
        };

        btnMDBFile = new Button {
          Location = new Point(280, 10),
          Size = new Size(30, 20),
          Text = "...",
        };

        clTables = new CheckedListBox  {
          Location = new Point(10, 30),
          Size = new Size(300, 200),
          Text = "...",
        };

        btnDBList = new Button {
          Location = new Point(10, 230),
          Size = new Size(30, 20),
          Text = "ls",
        };

        txtPostgreSQL = new TextBox {
          Location = new Point(40, 230),
          Size = new Size(270, 30),
          Text = "Server=192.168.33.20;Port=5432;User Id=postgres;Password=vagrant;database=template1;",
        };

        cboDatabaseList = new ComboBox {
          Location = new Point(10, 250),
          Size = new Size(300, 30),
          Text = "",
        };

        btnConvert = new Button {
          Location = new Point(10, 270),
          Size = new Size(300, 50),
          Text = "execute",
        };

        this.Controls.Add(txtFileName);
        this.Controls.Add(btnMDBFile);
        this.Controls.Add(clTables);
        this.Controls.Add(txtPostgreSQL);
        this.Controls.Add(btnDBList);
        this.Controls.Add(cboDatabaseList);
        this.Controls.Add(btnConvert);
        this.Load += new EventHandler(Form1_Load);
        btnMDBFile.Click += new EventHandler(btnMDBFile_Click);
        btnDBList.Click += new EventHandler(btnDBList_Click);
        btnConvert.Click += new EventHandler(btnConvert_Click);
    }
开发者ID:norick1701,项目名称:ConvertPGSQLFromMDB,代码行数:60,代码来源:ConvertDB.cs


示例13: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        ComboBox1 = new ComboBox();
        ComboBox1.ID = "ComboBox1";
        ComboBox1.Width = Unit.Pixel(200);
        ComboBox1.DataSourceID = "sds1";
        ComboBox1.DataTextField = "CompanyName";
        ComboBox1.DataValueField = "CustomerID";

        ComboBox1Container.Controls.Add(ComboBox1);

        ComboBox2 = new ComboBox();
        ComboBox2.ID = "ComboBox2";
        ComboBox2.Width = Unit.Pixel(200);
        ComboBox2.DataSourceID = "sds1";
        ComboBox2.DataTextField = "CompanyName";
        ComboBox2.DataValueField = "CustomerID";
        ComboBox2.CssSettings.ItemsContainer = "ob_iCboIC center";

        ComboBox2Container.Controls.Add(ComboBox2);

        ComboBox3 = new ComboBox();
        ComboBox3.ID = "ComboBox3";
        ComboBox3.Width = Unit.Pixel(200);
        ComboBox3.DataSourceID = "sds1";
        ComboBox3.DataTextField = "CompanyName";
        ComboBox3.DataValueField = "CustomerID";
        ComboBox3.CssSettings.ItemsContainer = "ob_iCboIC right";

        ComboBox3Container.Controls.Add(ComboBox3);  
    }
开发者ID:veraveramanolo,项目名称:power-show,代码行数:31,代码来源:cs_customization_align.aspx.cs


示例14: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        ComboBox1 = new ComboBox();
        ComboBox1.ID = "ComboBox1";
        ComboBox1.Width = Unit.Pixel(250);
        ComboBox1.Height = Unit.Pixel(200);
        ComboBox1.DataTextField = "CountryName";
        ComboBox1.DataValueField = "CountryID";
        ComboBox1.AutoClose = false;
        ComboBox1.AllowCustomText = true;
        ComboBox1.AutoValidate = true;
        ComboBox1.AllowEdit = false;
        ComboBox1.OpenOnFocus = true;
        ComboBox1.EmptyText = "Select countries ...";
        ComboBox1.EnableVirtualScrolling = true;
        ComboBox1.EnableLoadOnDemand = true;
        ComboBox1.LoadingItems += ComboBox1_LoadingItems;
        ComboBox1.ClientSideEvents.OnItemClick = "ComboBox1_ItemClick";
        ComboBox1.SelectionMode = ListSelectionMode.Multiple;

        ComboBox1.ItemTemplate = new ItemTemplate();
        ComboBox1.FooterTemplate = new FooterTemplate();

        ComboBox1Container.Controls.Add(ComboBox1);
       
    }
开发者ID:veraveramanolo,项目名称:power-show,代码行数:26,代码来源:cs_integration_checkboxes_ondemand.aspx.cs


示例15: MainForm

	public MainForm ()
	{
		// 
		// _comboBox
		// 
		_comboBox = new ComboBox ();
		_comboBox.Enabled = false;
		_comboBox.Location = new Point (8, 8);
		_comboBox.Width = 200;
		Controls.Add (_comboBox);
		// 
		// _selectButton
		// 
		_selectButton = new Button ();
		_selectButton.Location = new Point (230, 8);
		_selectButton.Size = new Size (60, 20);
		_selectButton.Text = "Select";
		_selectButton.Click += new EventHandler (SelectButton_Click);
		Controls.Add (_selectButton);
		// 
		// MainForm
		// 
		ClientSize = new Size (300, 50);
		Location = new Point (250, 100);
		StartPosition = FormStartPosition.Manual;
		Text = "bug #371751";
		Load += new EventHandler (MainForm_Load);
	}
开发者ID:mono,项目名称:gert,代码行数:28,代码来源:MainForm.cs


示例16: layout

 private void layout(ref Grid grid)
 {
     grid.Children.Clear();
     spins = 0;
     List<int> values = Enumerable.Range(0, 36).ToList();
     StackPanel panel = new StackPanel();
     pocket = new Grid()
     {
         Height = 220,
         Width = 220,
         HorizontalAlignment = HorizontalAlignment.Center
     };
     ComboBox combobox = new ComboBox()
     {
         Margin = new Thickness(10),
         HorizontalAlignment = HorizontalAlignment.Center
     };
     combobox.ItemsSource = values;
     combobox.SelectedIndex = 0;
     combobox.SelectionChanged += (object sender, SelectionChangedEventArgs e) =>
     {
         pickValue = (int)((ComboBox)combobox).SelectedValue;
     };
     panel.Children.Add(pocket);
     panel.Children.Add(combobox);
     grid.Children.Add(panel);
 }
开发者ID:RoguePlanetoid,项目名称:Windows-10-Universal-Windows-Platform,代码行数:27,代码来源:Library.cs


示例17: main_form_loaded

    public void main_form_loaded()
    {
        TabControl TabCtrl = (TabControl)GetControl("tabZoneProperties");
        tabWeather = new TabPage("Weather");
        tabWeather.UseVisualStyleBackColor = true;
        TabCtrl.TabPages.Add(tabWeather);

        MainForm.Controls.Remove(TabCtrl);

        lblRain = new Label();
        lblRain.Text = "Rain Type";

        string[] types =  {"RAIN_NONE", "RAIN_OUTSIDE", "RAIN_OUTSIDE_DESERT",
                  "RAIN_BUILDING", "RAIN_BUILDING_TOP", "RAIN_BUILDING_BOTTOM",
                  "RAIN_CAVE", "RAIN_MINE", "RAIN_COAST", "RAIN_SEA" };

        cmbRain = new ComboBox();
        cmbRain.DropDownStyle = ComboBoxStyle.DropDownList;
        cmbRain.DropDownWidth = 200;
        cmbRain.Items.AddRange(types);
        cmbRain.SelectedIndex = -1;

        tabWeather.Controls.Add(cmbRain);
        tabWeather.Controls.Add(lblRain);

        lblRain.Location = new System.Drawing.Point(7, 10);
        cmbRain.Location = new System.Drawing.Point(65, 7);

        Load();
    }
开发者ID:Gargash,项目名称:fo2238,代码行数:30,代码来源:weather.cs


示例18: TitleWidget

    public TitleWidget()
        : base()
    {
        label0 = new Label ("");
        this.PackStart (label0, true, true, 0);

        labelTable = new Label ();
        this.PackStart (labelTable, false, true, 0);

        label1 = new Label (Mono.Posix.Catalog.GetString ("by"));
        this.PackStart (label1, false, true, 0);

        comboOrderBy = ComboBox.NewText ();
        comboOrderBy.Changed += OnComboChanged;
        this.PackStart (comboOrderBy, false, true, 0);

        label2 = new Label (",");
        this.PackStart (label2, false, true, 0);

        buttonSorting = new Button ();
        buttonSorting.Relief = ReliefStyle.None;
        buttonSorting.CanFocus = false;
        buttonSorting.Clicked += OnButtonSortingClicked;
        this.PackStart (buttonSorting, false, true, 0);

        this.Spacing = 5;
    }
开发者ID:MonoBrasil,项目名称:historico,代码行数:27,代码来源:TitleWidget.cs


示例19: CultureInfoEditor

        /// <summary>
        /// Default constructor builds a ComboBox inline editor template.
        /// </summary>
        public CultureInfoEditor()
        {
            // not using databinding here because Silverlight does not support
            // the WPF CultureConverter that is used by Blend.
            FrameworkElementFactory comboBox = new FrameworkElementFactory(typeof(ComboBox));
            comboBox.AddHandler(
                ComboBox.LoadedEvent,
                new RoutedEventHandler(
                    (sender, e) =>
                    {
                        _owner = (ComboBox)sender;
                        _owner.SelectionChanged += EditorSelectionChanged;
                        INotifyPropertyChanged data = _owner.DataContext as INotifyPropertyChanged;
                        if (data != null)
                        {
                            data.PropertyChanged += DatacontextPropertyChanged;
                        }
                        _owner.DataContextChanged += CultureDatacontextChanged;
                    }));

            comboBox.SetValue(ComboBox.IsEditableProperty, false);
            comboBox.SetValue(ComboBox.DisplayMemberPathProperty, "DisplayName");
            comboBox.SetValue(ComboBox.ItemsSourceProperty, CultureInfo.GetCultures(CultureTypes.SpecificCultures));
            DataTemplate dt = new DataTemplate();
            dt.VisualTree = comboBox;

            InlineEditorTemplate = dt;
        }
开发者ID:modulexcite,项目名称:SilverlightToolkit,代码行数:31,代码来源:CultureInfoEditor.cs


示例20: AddButton

	public static void AddButton(ComboBox box, string text)
	{
		//Debug.Log("Adding button...");
		GameObject panel = box.transform.FindChild("Panel").gameObject;
		List<GameObject> children = new List<GameObject>(box.transform.FindChild("Panel").childCount);
		for (int i = 0; i < box.transform.FindChild("Panel").childCount; i++)
			children.Add(panel.transform.GetChild(i).gameObject);
		if (children.Exists(child => child.transform.FindChild("Text").GetComponent<Text>().text == text)) return;
		GameObject newButton = GameObject.Instantiate(box.transform.FindChild("ComboButton").gameObject) as GameObject;
		GameObject parent = box.transform.parent.gameObject;
		float canvasScaleFactor = box.RootCanvas.GetComponent<Canvas>().scaleFactor;
		newButton.transform.SetParent(box.gameObject.transform.FindChild("Panel"));	
		newButton.GetComponent<Button>().onClick.RemoveAllListeners();
		newButton.GetComponent<Button>().onClick.AddListener(() => box.comboButtonPressed(newButton));
		newButton.transform.FindChild("Text").GetComponent<Text>().text = text;
		RectTransform buttonTransform = newButton.GetComponent<RectTransform>();
		RectTransform panelTransform = box.gameObject.transform.FindChild("Panel").gameObject.GetComponent<RectTransform>();
		Rect buttonRect = buttonTransform.rect;
		Rect panelRect = panelTransform.rect;
		//float distance = box.ButtonDistance / canvasScaleFactor;
		//Debug.Log(distance);
		float offset = buttonRect.height * (box.buttons.Count); //+ distance;
		Vector2 panelPos = panelTransform.anchoredPosition;
		//Debug.Log(panelPos);
		Vector2 buttonPos = new Vector2(panelTransform.anchoredPosition.x, panelTransform.anchoredPosition.y - offset);
		//Debug.Log (buttonPos);
		buttonTransform.anchoredPosition = buttonPos;
		float newHeigth = buttonRect.height * (box.buttons.Count + 1.0f);// + distance;
		panelTransform.sizeDelta = new Vector2(panelRect.width, newHeigth);
		newButton.transform.localScale = newButton.transform.localScale * canvasScaleFactor;
		box.buttons.Add(newButton);
		if (box.buttons.Count == 1)
			box.transform.FindChild("ComboButton").FindChild("Text").gameObject.GetComponent<Text>().text = text;
	}
开发者ID:vs-team,项目名称:casanova-mk2,代码行数:34,代码来源:ComboBox.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ComboBoxEntry类代码示例发布时间:2022-05-24
下一篇:
C# CombinedQuery类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap