@@@@@@关于控件的缩放,如何实现?@@@@@@@

xfcsdn 2004-08-16 01:20:50
求Panel 控件重写,以实现可自由缩放调整大小的效果,的代码。
...全文
125 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
BearRui 2004-10-23
  • 打赏
  • 举报
回复
设置好控件的dock和Anchor属性能实现比较常见、简单的控件自动缩放的!!!
echoxue 2004-10-23
  • 打赏
  • 举报
回复
up
happyjun2000 2004-10-23
  • 打赏
  • 举报
回复
顶,接点分^_^
无聊就接分来了
ffb 2004-09-15
  • 打赏
  • 举报
回复
Windows 窗体 Splitter 控件提供一种调整复杂用户界面大小的简单方法。通过设置控件的 Dock 属性和控件的 Z 顺序(控件在窗体的 Z 轴上的位置),可以制作出直观易用的用户界面。

注意 也可通过右击并选择 BringToFront 或 SendToBack 来操作控件的 Z 顺序。有关 Windows 窗体上控件的 Z 顺序的更多信息,请参见将 Windows 窗体上的对象分层。
此外,建议在可滚动控件中停靠控件时添加一个子级可滚动控件(如 Panel 控件),使之包含其他任何可能需要滚动的控件。子级 Panel 控件应添加到可滚动控件中,同时将它的 Dock 属性设置为 DockStyle.Fill,并将它的 AutoScroll 属性设置为 true。父级可滚动控件的 AutoScroll 属性应设置为 false。
本例创建类似于在 Microsoft Outlook 中使用的多窗格用户界面。本例着重说明在窗体上排列 Splitter 和其他控件的方法,而不是说明如何添加功能使应用程序用于特定目的。它使 TreeView 控件停靠在窗体的左边。窗体的右边包含 Panel 控件,其中的 ListView 控件位于 RichTextBox 控件的上方。用户界面通过两个 Splitter 控件来管理,这两个控件允许单独调整其他控件的大小。TreeView 和 ListView 控件用于显示数据,而 Panel 控件维护正确的调整大小行为。可以改编此过程中的方法,制作出您自己的自定义用户界面。

设计时创建 Outlook 样式的用户界面

创建新的 Windows 应用程序项目。有关详细信息,请参见创建 Windows 应用程序项目。
将 TreeView 控件从“工具箱”拖动到窗体。在“属性”窗口中,通过单击值编辑器(在单击下箭头时显示)中的左窗格将 Dock 属性设置为 Left。
将 Splitter 控件从“工具箱”拖动到窗体。它将自动停靠在 TreeView 控件的右边缘。
将 Panel 控件从“工具箱”拖动到窗体。在“属性”窗口中,通过单击值编辑器(在单击下箭头时显示)中的中间窗格将 Dock 属性设置为 Fill。窗格将完全填充窗体的右侧。
将 ListView 控件从“工具箱”拖动到已添加到窗体的 Panel 控件上。将 ListView 控件的 Dock 属性设置为 Top。
将 Splitter 控件从“工具箱”拖动到已添加到窗体的 Panel 控件上。在“属性”窗口中,通过单击值编辑器(在单击下箭头时显示)中的顶窗格将 Dock 属性设置为 Top。这将使其停靠在 ListView 控件的底部。
将 RichTextBox 控件从“工具箱”拖动到 Panel 控件上。将 RichTextBox 控件的“Dock”属性设置为“Fill”。
按 F5 键运行该应用程序。
窗体显示由三部分组成的用户界面,类似于 Microsoft Outlook 的用户界面。注意:将鼠标拖动到任何一个 Splitter 控件上时,可以调整窗口大小。
ffb 2004-09-15
  • 打赏
  • 举报
回复
// C#
public void OutlookUI()
{
// Create an instance of each control being used.
this.treeView1 = new System.Windows.Forms.TreeView();
this.listView1 = new System.Windows.Forms.ListView();
this.richTextBox1 = new System.Windows.Forms.RichTextBox();
this.splitter2 = new System.Windows.Forms.Splitter();
this.splitter1 = new System.Windows.Forms.Splitter();
this.panel1 = new System.Windows.Forms.Panel();
// Insert code here to hook up event methods.

// Set properties of TreeView control.
this.treeView1.Dock = System.Windows.Forms.DockStyle.Left;
this.treeView1.Width = this.ClientSize.Width / 3;
this.treeView1.TabIndex = 0;
this.treeView1.Nodes.Add("treeView");

// Set properties of ListView control.
this.listView1.Dock = System.Windows.Forms.DockStyle.Top;
this.listView1.Height = this.ClientSize.Height * 2 / 3;
this.listView1.TabIndex = 0;
this.listView1.Items.Add("listView");

// Set properties of RichTextBox control.
this.richTextBox1.Dock = System.Windows.Forms.DockStyle.Fill;
this.richTextBox1.TabIndex = 2;
this.richTextBox1.Text = "richTextBox1";

// Set properties of Panel's Splitter control.
this.splitter2.Dock = System.Windows.Forms.DockStyle.Top;
// Width is irrelevant if splitter is docked to Top.
this.splitter2.Height = 3;
// Use a different color to distinguish the two splitters.
this.splitter2.BackColor = Color.Blue;
this.splitter2.TabIndex = 1;
// Set TabStop to false for ease of use when negotiating
// the user interface.
this.splitter2.TabStop = false;

// Set properties of Form's Splitter control.
this.splitter1.Location = new System.Drawing.Point(121, 0);
this.splitter1.Size = new System.Drawing.Size(3, 273);
this.splitter1.BackColor = Color.Red;
this.splitter1.TabIndex = 1;
// Set TabStop to false for ease of use when negotiating
// the user interface.
this.splitter1.TabStop = false;

// Add the appropriate controls to the Panel.
// The order of the controls in this call is critical.
this.panel1.Controls.AddRange(new System.Windows.Forms.Control[]
{richTextBox1, splitter2, listView1});

// Set properties of Panel control.
this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel1.TabIndex = 2;

// Add the rest of the controls to the form.
// The order of the controls in this call is critical.
this.Controls.AddRange(new System.Windows.Forms.Control[]
{panel1, splitter1, treeView1});
this.Text = "Intricate UI Example";
}
ffb 2004-09-15
  • 打赏
  • 举报
回复
为什么要重写,直接不就有这个功能吗,去看MSDN的例子,简单的很
happyjun2000 2004-09-07
  • 打赏
  • 举报
回复
同样up
zhpsam109 2004-08-18
  • 打赏
  • 举报
回复
来了几次,没有人回,帮你up!

17,740

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 .NET Framework
社区管理员
  • .NET Framework社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧