c# - 并排显示表单所有者表单
问题描述
我有一个表格。如果有人按下按钮,我想显示第二个“附加”到原始表单的表单,这意味着它的左侧位于原始表单的右侧并且它们具有相同的高度。换句话说:它们相互接触。
答案似乎是父表格旁边的开放表格
但是,图像之间存在间隙。我希望它们彼此完全相邻
主要形式:
private void ShowOtherForm()
{
using (var form = new OtherForm())
{
var dlgResult = form.ShowDialog(this);
ProcessDlgResult(dlgResult);
}
}
其他形式,事件处理程序加载
private void FormLoad(object sender, EventArgs e)
{
// show this form attached to the right side of my owner:
this.Location = new Point(this.Owner.Right, this.Owner.Top);
this.Height = this.Owner.Height;
}
解决方案
尝试使用ClientSize
和Location
private void Form2_Load(object sender, EventArgs e)
{
var owner = this.Owner;
Location = new Point(owner.Location.X + owner.ClientSize.Width, owner.Location.Y);
Height = owner.Height;
}
推荐阅读
- ruby-on-rails - 为什么我会收到“目标元素缺失”错误?
- sql - PostgreSQL ERROR 列不存在引用了一个列值
- c# - 使用 Saxon-HE 和 C# 在 XQuery 中查找所有 XPath
- r - mlr3 - 对新数据应用预处理
- javascript - 是否可以通过提供路径将文件从 Electron 应用程序发送到 Express 服务器?
- python - 如何在pyspark上使用嵌入式结构数组和数组连接两个配置单元表
- huggingface-tokenizers - 用余数迭代 Huggingface 分词器
- r - 加载 tidyverse 导致错误消息没有名为“readr”的包
- r - 如何在保留 R 中的一些变量的同时将 Long 重塑为 Wide
- r - 运行 GBM 时如何修复 PSOCKcluster 错误