首页 > 代码库 > winform Label与DataGridView右对齐

winform Label与DataGridView右对齐

实现Label与DataGridView对齐有两种方法,差别不大:

定义:

Label名称:lblName

DataGridView名称:dgvData

第一种:

 lblName.Location = new Point(dgvData.Location.X + dgvData.Width - lblName.Width, lblName.Location.Y);

第二种:

 lblName.Location = new System.Drawing.Point(dgvData.Location.X + dgvData.Width - lblName.Width, lblName.Location.Y);