Beispiel #1
0
        private void SQLServerComboBox_DropDown(object sender, System.EventArgs e)
        {
            SQLServerComboBox.Items.Clear();

            string [] servers = SqlLocator.GetServers();
            if (servers != null)
            {
                this.Cursor = Cursors.WaitCursor;
                Application.DoEvents();

                foreach (string server in servers)
                {
                    SQLServerComboBox.Items.Add(server);
                }

                this.Cursor = Cursors.Default;
            }
            else
            {
                SQLServerComboBox.Items.Add(MOG_ControllerSystem.GetComputerName());
            }
        }
Beispiel #2
0
        private void btnGetList_Click(object sender, EventArgs e)
        {//查找局域网的服务器列表
            if (_SrvList != null && _SrvList.Items.Count > 0)
            {
                _SrvList.Visible = true;
                _SrvList.Focus();
                this.Cursor = Cursors.Default;
                return;
            }

            try
            {
                ShowWaitCursor();
                _SrvList                       = new ListBox();
                _SrvList.Visible               = false;
                _SrvList.Parent                = this;
                _SrvList.Width                 = txtServerName.Width;
                _SrvList.Location              = new Point(txtServerName.Left, txtServerName.Top + txtServerName.Height + 1);
                _SrvList.SelectedIndexChanged += new EventHandler(SrvList_SelectedIndexChanged);
                string[] srvs = SqlLocator.GetServers();
                foreach (string srv in srvs)
                {
                    _SrvList.Items.Add(srv);
                }

                if (_SrvList.Items.Count > 0)
                {
                    _SrvList.Visible = true;
                    _SrvList.BringToFront();
                }
            }
            finally
            {
                ShowDefaultCursor();
            }
        }