本文整理汇总了C#中System.Windows.Forms.AutoSizeMode枚举的典型用法代码示例。如果您正苦于以下问题:C# AutoSizeMode枚举的具体用法?C# AutoSizeMode怎么用?C# AutoSizeMode使用的例子?那么恭喜您, 这里精选的枚举代码示例或许可以为您提供帮助。
在下文中一共展示了AutoSizeMode枚举的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Form1_Load
private void Form1_Load(object sender, EventArgs e)
{
this.AutoSize = true;
this.AutoSizeMode = AutoSizeMode.GrowAndShrink;
this.Text = "URL Opener";
flowPanel = new FlowLayoutPanel();
flowPanel.AutoSize = true;
flowPanel.AutoSizeMode = AutoSizeMode.GrowAndShrink;
this.Controls.Add(flowPanel);
urlLabel = new Label();
urlLabel.Name = "urlLabel";
urlLabel.Text = "URL:";
urlLabel.Width = 50;
urlLabel.TextAlign = ContentAlignment.MiddleCenter;
flowPanel.Controls.Add(urlLabel);
urlTextBox = new TextBox();
urlTextBox.Name = "urlTextBox";
urlTextBox.Width = 250;
flowPanel.Controls.Add(urlTextBox);
urlButton = new Button();
urlButton.Name = "urlButton";
urlButton.Text = "Open URL in Browser";
urlButton.Click += new EventHandler(urlButton_Click);
flowPanel.Controls.Add(urlButton);
}
void urlButton_Click(object sender, EventArgs e)
{
try
{
Uri newUri = new Uri(urlTextBox.Text);
}
catch (UriFormatException uriEx)
{
MessageBox.Show("Sorry, your URL is malformed. Try again. Error: " + uriEx.Message);
urlTextBox.ForeColor = Color.Red;
return;
}
// Valid URI. Reset any previous error color, and launch the URL in the
// default browser.
// NOTE: Depending on the user's settings, this method of starting the
// browser may use an existing window in an existing Web browser process.
// To get around this, start up a specific browser instance instead using one of
// the overloads for Process.Start. You can examine the registry to find the
// current default browser and launch that, or hard-code a specific browser.
urlTextBox.ForeColor = Color.Black;
Process.Start(urlTextBox.Text);
}
开发者ID:.NET开发者,项目名称:System.Windows.Forms,代码行数:53,代码来源:AutoSizeMode
注:本文中的System.Windows.Forms.AutoSizeMode枚举示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论