I have a requirement to build an “inline editing experience”. Here is what this means. On a form you have a label – you click the label and an edit box appears, allowing you to change the value that was in the label.
I can do this with a UserPopup control – but I’m trying to have the popup control appear ON TOP of the label control.
If I call .ShowPopup(label) then it appears right beneath the label. That is not ideal – we want it to appear on top of, or in place of, the label.
So I’m trying to use one of the other overrides w/ ShowPopup. But of course the label can be in a panel, which can be in some other container etc.
Basically I need to get the screen coordinates location of the label control, and then place the popup there. I’ve been trying different ways of using label.PointToScreen to do this – but I’m not getting the results I expect so I suspect I am doing it wrong.
I thought this would work: .ShowPopup(label.PointToScreen(label.Location)) – but it does not. The popup is always below and to the right. Shouldn’t it return absolute screen coordinates. Or am I using these methods incorrectly?
Any advice would be appreciated!
Thanks in advance,
You can do that like in two ways:
The PointToScreen() method translates the client point to a screen point and if you use label1.PointToScreen(100,100) it translates the 100,100 location “inside” label1 to the corresponding screen location. This is a common error when translating client to screen and back.
You could also use this.label1.PointToScreen(Point.Empty), which is the same as this.label1.Parent.PointToScreen(this.label1.Location).
Please login first to submit.