UserControl在VisualStudio中停靠

编程入门 行业动态 更新时间:2024-10-24 14:24:47
本文介绍了UserControl在VisualStudio中停靠的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

大家好我在这里这是我的任务,我想知道如何停靠用户控制让我解释我想要的东西, 我设计的From1和UserControl1和这个Form1,它的panel1和toolStripButton1。按钮设置调用UserControl1它没关系,但我不知道如何设置它自动调整Form1的panel1宽度和高度。所以任何人都可以帮助我 UserControl1

Hi everyone I here this is a my assignment, I want to know how can dock an User Control let me explain what I want, I designed From1 and UserControl1 and this the Form1, its panel1 and toolStripButton1. button set to call UserControl1 its ok, but i don't know how can I set it to automatically resize with Form1's panel1 width and height. so can anyone help me please UserControl1

using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Linq; using System.Text; using System.Windows.Forms; namespace XyZ { public partial class UserControl1 : UserControl { public UserControl1() { InitializeComponent(); } private void UserControl1_Load(object sender, EventArgs e) { } private void textBox1_TextChanged(object sender, EventArgs e) { } } }

Form1--

Form1--

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace XyZ { public partial class CustomerInvoice : Form { public CustomerInvoice() { InitializeComponent(); } private void toolStripButton1_Click(object sender, EventArgs e) { panel1.Controls.Clear(); UserControl1 ust2 = new UserControl1(); panel1.Controls.Add(ust2); } private void menuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e) { } private void panel1_Paint(object sender, PaintEventArgs e) { } } }

推荐答案

最简单的方法是使用Dock或主播属性: https:// msdn.microsoft/en-us/library/vstudio/77cb86s0(v=vs.100).aspx [ ^ ] msdn.microsoft/en-us/library/system.windows.forms.control.anchor(V = vs.110)的.aspx [ ^ ] Dock适合控件到边缘,Anchor将它们锁定到边缘。 The easiest way is to use the Dock or Anchor properties: msdn.microsoft/en-us/library/vstudio/77cb86s0(v=vs.100).aspx[^] msdn.microsoft/en-us/library/system.windows.forms.control.anchor(v=vs.110).aspx[^] Dock "fits" controls to edges, Anchor "locks" them to edges.

更多推荐

UserControl在VisualStudio中停靠

本文发布于:2023-11-08 13:36:56,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1569519.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:UserControl   VisualStudio

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!