UserPopup control question

Welcome to Wisej Support.
Questions, suggestions and plain old bugs - are all welcome here!
Answered
0
0

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,

 

Matthew

 

  • You must to post comments
Best Answer
0
0

You can do that like in two ways:

  1. Use userPopup1.ShowPopup(this.label1); The default alignment is BottomLeft. It will automatically align the popup below the opener aligned to the left and it will keep the aligment. It will also automatically adjust the position to ensure that the popup is visible in case the opener (label1) position would cause the popup to be partially outside of the browser. Just like the combobox drop down. To move the popup up in order to conver the opener you can use the Offset property of the popup: this.userPopup1.Offset = new Padding(0, -this.label1.Height, 0,0); to offset the top the height of the opener.
  2. Use userPopup1.ShowPopup(this.label1.Parent.PointToScreen(this.label1.Location); In this case the position is programmatic since there is no opener specified and you can position the popup anywhere.

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).

HTH

 

 

  • You must to post comments
0
0

Thanks Luca – I finally got a chance to come back to this and implemented your suggestion number one.  The offset property was exactly what I was looking for.  I appreciate the assist – it works perfectly.

 

Thanks,

 

Matthew

  • You must to post comments
Showing 2 results
Your Answer
Post as a guest by filling out the fields below or if you already have an account.
Name*
E-mail*
Attachment
File Name Size
There are currently no files uploaded.
Maximum number of files 5, maximum file size 3.9MB.
Supported file formats: zip pdf gif jpg bmp png cs vb theme json