Пример #1
0
 private void comboBoxRiverSystems_SelectedIndexChanged(object sender, EventArgs e)
 {
     toolStripStatusLabel1.Text = "Requesting River Sites API Data...";
     statusStrip1.Refresh();
     if (comboBoxRiverSystems.SelectedValue is string)
     {
         this.comboBoxRiverSites.DataSource = null;
         this.comboBoxRiverSites.Items.Clear();
         var dTab = IDWRDailySeries.GetIdwrRiverSites(this.comboBoxRiverSystems.SelectedValue.ToString());
         riverSitesTable = dTab;
         FilterSites();
     }
 }
Пример #2
0
        private void comboBoxRiverSystems_SelectedIndexChanged(object sender, EventArgs e)
        {
            toolStripStatusLabel1.Text = "Requesting River Sites API Data...";
            statusStrip1.Refresh();
            if (comboBoxRiverSystems.SelectedValue is string)
            {
                this.comboBoxRiverSites.DataSource = null;
                this.comboBoxRiverSites.Items.Clear();
                var dTab = IDWRDailySeries.GetIdwrRiverSites(this.comboBoxRiverSystems.SelectedValue.ToString());
                this.comboBoxRiverSites.DataSource    = dTab;
                this.comboBoxRiverSites.ValueMember   = "SiteID";
                this.comboBoxRiverSites.DisplayMember = "SiteName";

                ComboBox senderComboBox = this.comboBoxRiverSites;
                int      width          = senderComboBox.DropDownWidth;
                Graphics g    = senderComboBox.CreateGraphics();
                Font     font = senderComboBox.Font;
                int      vertScrollBarWidth =
                    (senderComboBox.Items.Count > senderComboBox.MaxDropDownItems)
                    ? SystemInformation.VerticalScrollBarWidth : 0;

                int newWidth, maxWidth = 156;
                for (int i = 0; i < dTab.Rows.Count; i++)
                {
                    string s = dTab.Rows[i]["SiteName"].ToString();
                    newWidth = (int)g.MeasureString(s, font).Width
                               + vertScrollBarWidth;
                    if (maxWidth < newWidth)
                    {
                        maxWidth = newWidth;
                    }
                }
                senderComboBox.DropDownWidth = maxWidth;
                toolStripStatusLabel1.Text   = "Done!";
                ValidateDates(sender, e);
            }
        }