Click here to Skip to main content
13,588,935 members
Click here to Skip to main content
Add your own
alternative version


67 bookmarked
Posted 4 May 2006
Licenced CPOL

A Floating Popup Control

, 4 May 2006
Rate this:
Please Sign up or sign in to vote.
A floating popup control which can display any form.

Sample Image - FloatingPopup.jpg


I have written an article in CodeProject titled as "A Calculator Control Box". It was useful to many developers like me. Some did not use the calculator control directly in their project. They modified the control to display it as a different control in a popup form. By this time, I needed the same thing too. So, I modified the control to display in any form as a popup window.


To display your own form in the floating popup control, you need to implement an interface named IFloatingPopup. The interface is something like...

public interface IFloatingPopup
    event CancelEventHandler PopupHiding;
    event CancelEventHandler PopupShowing;
    event EventHandler PopupHidden;
    event EventHandler PopupShown;
    void Show();
    void Hide();
    void ForceShow();
    System.Windows.Forms.UserControl UserControl
    void SetAutoLocation();
    Form PopupForm

In the implementation, Show and Hide have already been implemented in your form. You can inherit frmFloatingBase where the interface has been implemented. So, you don't need to think about its implementation.

To use your own form, the following steps will help you...

frmFloatingDerived myderivedForm=new frmFloatingDerived();

The floating popup control has all the features of the calculator control, like auto-positioning the popup window. It displays the floating window at the best possible position in accordance to the control position at the screen.

Calculator Box Control

The CalculatorBox is a user control, which provides specific features to provide numeric input, especially for financial information. This control can be used as a text box control. It is more like a combo box control. It has two modes. One is the normal mode where the user can provide input for a decimal number. Whenever the user wants to do some mathematical operations, the user can click on the arrow at the left, like in a combo box. It will display a calculator at the best possible place. The user can click on the calculator buttons, or use the keyboard to do the calculator. In text mode, if the user clicks any operation key (Add, Subtract, Multiply, or Divide), then it will automatically switch to the calculator mode with the button pressed. If the calculator loses its focus, then automatically, it will switch to text mode and the calculator will disappear.

Sample Image

If the user made some mistake in the calculation and wants to go back to the previous value, then user can press the Esc button. It will re-set to the previous value.

This control has two properties. The Text property will provide whatever is available in the text box, and the Value property will provide the decimal value.

Culture Support

I use the current culture information from the CultureInfo class to decide the character for the decimal point. The decimal point is used for display as well as to accept input from the user. For example, the Spanish language uses coma as a decimal separator. So, if the user sets the current culture as Spanish, then the calculator control will automatically use the coma as the decimal separator.

Culture Support


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

H. S. Masud
Software Developer (Senior) KAZ Software Limited
Bangladesh Bangladesh
No Biography provided

You may also be interested in...


Comments and Discussions

Questioncalculatorbox component for .net compact framework ? Pin
davicef8-Jul-08 11:47
memberdavicef8-Jul-08 11:47 
AnswerRe: calculatorbox component for .net compact framework ? Pin
H. S. Masud8-Jul-08 19:15
memberH. S. Masud8-Jul-08 19:15 
QuestionOccur Dialog "A project with an Output Type of Class Library cannot be started directly" Pin
lnakarin1-Feb-07 18:02
memberlnakarin1-Feb-07 18:02 
AnswerRe: Occur Dialog "A project with an Output Type of Class Library cannot be started directly" Pin
H. S. Masud2-Feb-07 21:25
memberH. S. Masud2-Feb-07 21:25 
GeneralRe: Occur Dialog "A project with an Output Type of Class Library cannot be started directly" Pin
lnakarin5-Feb-07 15:28
memberlnakarin5-Feb-07 15:28 
NewsMainform loses focuc - Solution Pin
Julian Ott14-Oct-06 11:42
memberJulian Ott14-Oct-06 11:42 
GeneralNice one Pin
fwsland23-Jul-06 5:45
memberfwsland23-Jul-06 5:45 
GeneralRe: Nice one Pin
H. S. Masud23-Jul-06 22:40
memberH. S. Masud23-Jul-06 22:40 
GeneralThe main form loses focus Pin
Eugene Zolotko5-May-06 22:07
memberEugene Zolotko5-May-06 22:07 
NewsRe: The main form loses focus Pin
H. S. Masud5-May-06 22:15
memberH. S. Masud5-May-06 22:15 
GeneralRe: The main form loses focus Pin
Paul Bludov9-May-06 14:48
memberPaul Bludov9-May-06 14:48 
JokeRe: The main form loses focus Pin
H. S. Masud9-May-06 19:39
memberH. S. Masud9-May-06 19:39 
GeneralRe: The main form loses focus Pin
kleinecools21-Jun-06 21:29
memberkleinecools21-Jun-06 21:29 
GeneralRe: The main form loses focus Pin
Member 43423169-Jun-11 3:58
memberMember 43423169-Jun-11 3:58 
GeneralExcellent Calculator Control !!! Pin
Marcos Meli4-May-06 6:11
memberMarcos Meli4-May-06 6:11 
JokeRe: Excellent Calculator Control !!! Pin
H. S. Masud5-May-06 19:15
memberH. S. Masud5-May-06 19:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web02-2016 | 2.8.180615.1 | Last Updated 4 May 2006
Article Copyright 2006 by H. S. Masud
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid