确定C#标签特定部分的左上角(位置)
我有一个窗口表单,可以在编程中创建的控制标签上拖动。我正在使用位置属性来确定每个标签位置。
每个标签都是用占位符'#'的预览创建的。我想知道该标签中特定字符的形式坐标是什么。
作为代码示例:
Label myLabel = new Label
{
Text = "Average: ##.#Unit",
Name = "myLabelName"
};
Controls.Add(myLabel);
...
// After label is dragged around
Point myLabelLocation = myLabel.Location;
这给了我标签的坐标。假设我想要类似的坐标,但是我希望它们成为第一个#。
看这件事的另一种方法是,我在'#'之前就“拆分”了标签。我如何获得这个位置?
I have a windows form that I can drag around programmatically created control labels. I am using the location property to determine each label position.
Each label is created as a preview with placeholder '#' where a number is to be. I want to know what the form coordinates are of a specific character in that label.
As a code example:
Label myLabel = new Label
{
Text = "Average: ##.#Unit",
Name = "myLabelName"
};
Controls.Add(myLabel);
...
// After label is dragged around
Point myLabelLocation = myLabel.Location;
This gives me the label's coordinates. Let's say I want similar coordinates, but I want them for the first #.
Another way to look at this, I "split" the label right before '#'. How do I get this location?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论