Exemplo n.º 1
0
        /// <summary>
        /// Initializes the contents of a <see cref="ComboBox"/> with character sets and their corresponding collations.
        /// </summary>
        /// <param name="comboBox">The <see cref="ComboBox"/> to initialize.</param>
        /// <param name="connection">MySQL Workbench connection to a MySQL server instance selected by users.</param>
        /// <param name="firstElement">A custom string for the first element of the dictioary.</param>
        public static void SetupCollations(this ComboBox comboBox, MySqlWorkbenchConnection connection, string firstElement)
        {
            if (comboBox == null)
            {
                return;
            }

            var collationsDictionary = connection.GetCollationsDictionary(firstElement);

            if (collationsDictionary == null)
            {
                return;
            }

            comboBox.DataSource    = new BindingSource(collationsDictionary, null);
            comboBox.DisplayMember = "Value";
            comboBox.ValueMember   = "Key";
        }