searchsettings.cs

来自「Accessing microsoft live web services fr」· CS 代码 · 共 69 行

CS
69
字号
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using LiveExpoService;

namespace LiveExpoApp
{
    public partial class SearchSettings : Form
    {
        public SearchSettings()
        {
            InitializeComponent();
        }

        private void SearchSettings_Load(object sender, EventArgs e)
        {
            textBoxCity.Text = LiveExpoHelper.SearchCity;
            textBoxZIP.Text = LiveExpoHelper.SearchZIP;
            textBoxState.Text = LiveExpoHelper.SearchState;
            textBoxCountry.Text = LiveExpoHelper.SearchCountry;
            textBoxDistance.Text = LiveExpoHelper.SearchDistance.ToString("N0");
        }

        private void menuItemCancel_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.Cancel;
            this.Close();
        }

        private void menuItemOK_Click(object sender, EventArgs e)
        {
            LiveExpoHelper.SearchCity = textBoxCity.Text;
            LiveExpoHelper.SearchZIP = textBoxZIP.Text;
            LiveExpoHelper.SearchState = textBoxState.Text;
            LiveExpoHelper.SearchCountry = textBoxCountry.Text;
            LiveExpoHelper.SearchDistance = Convert.ToSingle(textBoxDistance.Text);
            DialogResult = DialogResult.OK;
            this.Close();
        }

        private void textBoxDistance_Validating(object sender, CancelEventArgs e)
        {
            float f = 0;
            if (textBoxDistance.Text.Length != 0)
            {
                try
                {
                    f = System.Convert.ToSingle(textBoxDistance.Text);
                }
                catch (System.OverflowException)
                {
                    MessageBox.Show("Value too large!");
                    e.Cancel = true;
                    textBoxDistance.Select(0, textBoxDistance.Text.Length);
                }
                catch (System.FormatException)
                {
                    MessageBox.Show("Enter a valid number");
                    e.Cancel = true;
                    textBoxDistance.Select(0, textBoxDistance.Text.Length);
                }
            }
        }
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?