System.Windows.Forms.ToolStripItemCollection.IndexOfKey C# (CSharp) Method

IndexOfKey() public method

public IndexOfKey ( string key ) : int
key string
return int
		public virtual int IndexOfKey (string key)
		{
			ToolStripItem tsi = this[key];

			if (tsi == null)
				return -1;

			return this.IndexOf (tsi);
		}

Usage Example

コード例 #1
0
ファイル: MainWindow.cs プロジェクト: slavkur/WarehouseApp
        private int DBSelect_LoadingLists_Reset()
        {
            DataTable openedLists = new DataTable();
            using (OleDbDataAdapter adapter = new OleDbDataAdapter("Select * from LoadingListOpened_View", conn))
            {
                adapter.SelectCommand.Parameters.Add("@stock_id", OleDbType.Integer).Value = getStockId();
                adapter.Fill(openedLists);
            }
            openedLists.PrimaryKey = new DataColumn[] { openedLists.Columns[openedLists.Columns.IndexOf("id")] };

            //checking for contained buttons, remove not existing in db
            KryptonCheckButton[] buttons = new KryptonCheckButton[openedLists.Rows.Count];
            ToolStripMenuItem[] items = new ToolStripMenuItem[openedLists.Rows.Count];
            foreach (DataRow row in openedLists.Rows)
            {
                long listId = long.Parse(row.ItemArray[openedLists.Columns.IndexOf("id")].ToString());
                string index = (string)row.ItemArray[openedLists.Columns.IndexOf("index")];
                KryptonCheckButton button = CreateLoadingListButton(listId, index);

                if (!flpControls.Controls.ContainsKey(button.Name))
                {
                    //buttons[openedLists.Rows.IndexOf(row)] = button;
                    flpControls.Controls.Add(button);
                    tsmiLL.DropDownItems.Insert(tsmiLL.DropDownItems.IndexOf(tsmiHistorySeparator), newLoadingListMenuItem(listId, index));
                    newLoadingListToolStripItem(listId, index);
                }
            }

            ToolStripItemCollection col2 = new ToolStripItemCollection(cmsLoadingLists, ((ToolStripItem[])cmsLoadingLists.Tag));
            foreach (Control control in flpControls.Controls)
            {
                if (!openedLists.Rows.Contains(control.Tag))
                {
                    flpControls.Controls.RemoveAt(flpControls.Controls.IndexOfKey(control.Name));

                    col2.RemoveAt(col2.IndexOfKey(csLoadingList.CheckedButton.Name));
                    col2.CopyTo((ToolStripItem[])cmsLoadingLists.Tag, 0);

                    tsmiLL.DropDownItems.RemoveAt(tsmiLL.DropDownItems.IndexOfKey(control.Name));
                }
            }

            //flpControls.Controls.AddRange(buttons);
            return openedLists.Rows.Count;
        }
All Usage Examples Of System.Windows.Forms.ToolStripItemCollection::IndexOfKey