 |
|
 |
Use the Close() method instead of Hide().
|
|
|
|
 |
|
 |
Lukasz,
Nice control and easy to use.
Thanks for the effort
|
|
|
|
 |
|
 |
Thanks and you’re welcome
|
|
|
|
 |
|
 |
Hi,
Wonderful article! One small problem: in application MoreComplexPopup, the dropdown for the PopupComboBox on the top right doesn't get focus (on Windows 7), so you need to click once for it to receive focus, and then click another time to click on an item.
Fix: in class PopupComboBox, method WndProc, do BeginInvoke(new MethodInvoker(ShowDropDown)); instead of ShowDropDown() directly.
Not sure why the original PopupComboBox won't focus properly though, it has something to do with the ComboBox/WndProc combination perhaps, because all the other drop down examples seem to Focus fine.
Wout
|
|
|
|
 |
|
 |
Thanks for finding and fixing the bug I’ll include this soon in the next version.
|
|
|
|
 |
|
 |
Saludos, maravilloso controls, despues de horas de trabajo, con su controls resolvi mi problema en 5 minutos.
|
|
|
|
 |
|
 |
heya lukasz,
thx for this nice control!
i am thinking about using this as a basis for a intellisense-like control
i want to type in a TextBox and on the TextChanged event i want to show the
popup and let it filter its ListBox.
i expected the property "FocusOnOpen" to help me achieve this. but the focus
after the popup is shown is not in the owner-form. a
((TextBox)sender).Focus();
doesnt help.
do you have an idea how to solve this?
best regards
|
|
|
|
 |
|
 |
ComboBoxes have something like this when you set the autocomplete to suggest
|
|
|
|
 |
|
 |
Dear,
When I try to add a form that is has the property (RightToLeft = RightToLeft.Yes); the popup throws the following exception (Error creating window handle.).
Note that the problem is solved when I changed the value of this property only and make it (RightToLeft = RightToLeft.No)
Code:
frmDetail.RightToLeft = RightToLeft.Yes;
Popup popupScreen;
popupScreen = new Popup(frmDetail);
//The last line throws the exception
Is there any solution for this problem because I want to add a RightToLeft form to the popup?
Thank you very much in advance for your cooperation.
Best Regards,
AbdelRahman Doghish
|
|
|
|
 |
|
 |
Hi.
Sorry for such late answer.
I cannot reproduce this behavior, that is setting popup’s parent RightToLeft to RightToLeft.Yes works fine.
Just don’t add a form as a child of popup, but an user control.
Regards,
Luke
|
|
|
|
 |
|
 |
Its a great resource! But i have 1 question. There is any posibility to accept a transparent user control and make the popup transparent?
This is how i see the image if i set the transparency: http://img267.imageshack.us/i/24902031.png/[^]
This is how i see the image withouth the transparency property set to true (the problem is that that shadow should be semi-transparent, but the backcolor is set to white): http://img442.imageshack.us/i/55940912.png/[^]
|
|
|
|
 |
|
|
 |
|
 |
I try to use Simple popup with Mono.
More info here:
CheckBox ComboBox Extending the ComboBox Class and Its Items[^]
The version used in CheckBoxComboBox does not use the P/Invoke AnimateWindow
However, the code still not works in Mono.
Same traceback appears when testing Mono with PopupTest.exe
Any hints what can be done to get the code work with Mono?
G:\Users\go\dev\SimplePopup>mono --debug MoreComplexPopup.exe
Unhandled Exception: System.NullReferenceException: Object reference not set to
an instance of an object
at PopupControl.Popup.OnSizeChanged (System.EventArgs e) [0x00000]
at System.Windows.Forms.Control.UpdateBounds (Int32 x, Int32 y, Int32 width, I
nt32 height, Int32 clientWidth, Int32 clientHeight) [0x000f2] in C:\cygwin\tmp\m
onobuild\build\BUILD\mono-2.4\mcs\class\Managed.Windows.Forms\System.Windows.For
ms\Control.cs:5191
at System.Windows.Forms.Control.UpdateBounds (Int32 x, Int32 y, Int32 width, I
nt32 height) [0x00023] in C:\cygwin\tmp\monobuild\build\BUILD\mono-2.4\mcs\class
\Managed.Windows.Forms\System.Windows.Forms\Control.cs:5152
at System.Windows.Forms.Control.SetBoundsCoreInternal (Int32 x, Int32 y, Int32
width, Int32 height, BoundsSpecified specified) [0x0012c] in C:\cygwin\tmp\mono
build\build\BUILD\mono-2.4\mcs\class\Managed.Windows.Forms\System.Windows.Forms\
Control.cs:5021
at System.Windows.Forms.Control.SetBoundsCore (Int32 x, Int32 y, Int32 width,
Int32 height, BoundsSpecified specified) [0x00000] in C:\cygwin\tmp\monobuild\bu
ild\BUILD\mono-2.4\mcs\class\Managed.Windows.Forms\System.Windows.Forms\Control.
cs:4967
at System.Windows.Forms.ToolStrip.SetBoundsCore (Int32 x, Int32 y, Int32 width
, Int32 height, BoundsSpecified specified) [0x00000] in C:\cygwin\tmp\monobuild\
build\BUILD\mono-2.4\mcs\class\Managed.Windows.Forms\System.Windows.Forms\ToolSt
rip.cs:1161
at System.Windows.Forms.ToolStripDropDown.SetBoundsCore (Int32 x, Int32 y, Int
32 width, Int32 height, BoundsSpecified specified) [0x00000] in C:\cygwin\tmp\mo
nobuild\build\BUILD\mono-2.4\mcs\class\Managed.Windows.Forms\System.Windows.Form
s\ToolStripDropDown.cs:688
at System.Windows.Forms.Control.SetBoundsInternal (Int32 x, Int32 y, Int32 wid
th, Int32 height, BoundsSpecified specified) [0x000a8] in C:\cygwin\tmp\monobuil
d\build\BUILD\mono-2.4\mcs\class\Managed.Windows.Forms\System.Windows.Forms\Cont
rol.cs:4422
at System.Windows.Forms.Control.SetBounds (Int32 x, Int32 y, Int32 width, Int3
2 height, BoundsSpecified specified) [0x00044] in C:\cygwin\tmp\monobuild\build\
BUILD\mono-2.4\mcs\class\Managed.Windows.Forms\System.Windows.Forms\Control.cs:4
407
at System.Windows.Forms.Control.set_Size (Size value) [0x00000] in C:\cygwin\t
mp\monobuild\build\BUILD\mono-2.4\mcs\class\Managed.Windows.Forms\System.Windows
.Forms\Control.cs:3277
at System.Windows.Forms.ToolStripDropDown.OnLayout (System.Windows.Forms.Layou
tEventArgs e) [0x0016d] in C:\cygwin\tmp\monobuild\build\BUILD\mono-2.4\mcs\clas
s\Managed.Windows.Forms\System.Windows.Forms\ToolStripDropDown.cs:614
at System.Windows.Forms.Control.PerformLayout (System.Windows.Forms.Control af
fectedControl, System.String affectedProperty) [0x00066] in C:\cygwin\tmp\monobu
ild\build\BUILD\mono-2.4\mcs\class\Managed.Windows.Forms\System.Windows.Forms\Co
ntrol.cs:4084
at System.Windows.Forms.Control.PerformLayout () [0x00000] in C:\cygwin\tmp\mo
nobuild\build\BUILD\mono-2.4\mcs\class\Managed.Windows.Forms\System.Windows.Form
s\Control.cs:4061
at System.Windows.Forms.Control.ResumeLayout (Boolean performLayout) [0x0007c]
in C:\cygwin\tmp\monobuild\build\BUILD\mono-2.4\mcs\class\Managed.Windows.Forms
\System.Windows.Forms\Control.cs:4274
at System.Windows.Forms.Control.ResumeLayout () [0x00000] in C:\cygwin\tmp\mon
obuild\build\BUILD\mono-2.4\mcs\class\Managed.Windows.Forms\System.Windows.Forms
\Control.cs:4255
at System.Windows.Forms.ToolStrip..ctor (System.Windows.Forms.ToolStripItem[]
items) [0x00128] in C:\cygwin\tmp\monobuild\build\BUILD\mono-2.4\mcs\class\Manag
ed.Windows.Forms\System.Windows.Forms\ToolStrip.cs:122
at System.Windows.Forms.ToolStrip..ctor () [0x00000] in C:\cygwin\tmp\monobuil
d\build\BUILD\mono-2.4\mcs\build\common\Consts.cs:1
at System.Windows.Forms.ToolStripDropDown..ctor () [0x00000] in C:\cygwin\tmp\
monobuild\build\BUILD\mono-2.4\mcs\build\common\Consts.cs:1
at PopupControl.Popup..ctor (System.Windows.Forms.Control content) [0x00000]
at (wrapper remoting-invoke-with-check) PopupControl.Popup:.ctor (System.Windo
ws.Forms.Control)
at MoreComplexPopup.MainForm..ctor () [0x00000]
at (wrapper remoting-invoke-with-check) MoreComplexPopup.MainForm:.ctor ()
at MoreComplexPopup.MainForm.Main () [0x00000]
G:\Users\go\dev\SimplePopup>
|
|
|
|
 |
|
 |
It looks like Mono’s Windows Forms still doesn’t work exactly like .NET’s Windows Forms.
Anyway… in the Popup.cs file, in method OnSizeChanged add "if (content != null)" checking… this fixes the NullReferenceException.
But the popups still don’t look very good because of bug in Mono, look here: http://go-mono.com/forums/#nabble-td22184714[^]
Łukasz
|
|
|
|
 |
|
 |
You may add this code as well to the Popup class, it fixes almost all bugs related to Mono.
protected override void OnLayout(LayoutEventArgs e)
{
Size suggestedSize = GetPreferredSize(Size.Empty);
if (AutoSize && suggestedSize != Size)
{
Size = suggestedSize;
}
SetDisplayedItems();
OnLayoutCompleted(EventArgs.Empty);
Invalidate();
}Łukasz
|
|
|
|
 |
|
 |
Thanks, great!
Any problem having this fix in .NET too or should the following be used?
public static bool IsRunningOnMono()
{
return Type.GetType("Mono.Runtime") != null;
}
protected override void OnLayout(LayoutEventArgs e)
{
if (IsRunningOnMono())
{
Size suggestedSize = GetPreferredSize(Size.Empty);
if (AutoSize && suggestedSize != Size)
{
Size = suggestedSize;
}
SetDisplayedItems();
OnLayoutCompleted(EventArgs.Empty);
Invalidate();
}
else
{
base.OnLayout(e);
}
}
I have not been able to fix my intended usage yet: CheckBoxComboBox uses an older version of Simple Popup, the test application itself is not working with Mono the plugin that uses CheckBoxComboBox has other issues too. Upgraded Simple Popup works slightly better.
/Gerhard
|
|
|
|
 |
|
 |
Checking for Mono would be good
private static bool? _isRunningOnMono;
public static bool IsRunningOnMono()
{
if (!_isRunningOnMono.HasValue)
_isRunningOnMono = Type.GetType("Mono.Runtime") != null;
return _isRunningOnMono.Value;
}
|
|
|
|
 |
|
|
 |
|
|
 |
|
 |
Hi,
I had a GroupBox which contain so many text boxes and labels alligned like a data entry form. i added one button and add this code in the button click.
ToolStripDropDown tspopUp = new ToolStripDropDown();
tspopUp.Margin = Padding.Empty;
tspopUp.Padding = Padding.Empty;
ToolStripControlHost host = new ToolStripControlHost(CategoryPanel);
host.Margin = Padding.Empty;
host.Padding = Padding.Empty;
tspopUp.Items.Add(host);
tspopUp.Show(GroupBox1,txtcategory.Location);
in a plain form if we add this, it will work nicely but if lot of control inside a form it will not popup. it's very bad.
How people told this code as excellent, i don't know.
Raj
|
|
|
|
 |
|
 |
Hi,
Well, you wrote to little I could help you. I've testes a form with 4 groupboxes, each of them contained 40 labels, 40 textboxes and 40 buttons, and all worked fine. Which version of .NET do you use? Have you installed latest service pack for the .NET you’re using?
Anyway… some time ago I’ve read an article which said that there is a bug in Windows Forms which occurs when there are very many controls on a Form. Maybe you had that “pleasure” to notice that bug. I don’t know.
Regards,
Łukasz
|
|
|
|
 |
|
 |
hai,
i am using the latest version to .net frame work. in my form i have lot of text boxes and label. i am added panel and trying to host that control in the toolstip host control. but it was not poping -up. After that i made it in a user control, then it start showing.
After this i implement this same user control in a DataGridView for populating data on clicking on the button in each row according to the key value in each row. But it disappointed me very much.Only once the data will get populate. next time onwards data is populating to the grid. but it's showing the frist populated data.
Can u check this dynamic databinding to a toolstripdropdown while clicking on each row of datagridview.
Raj
|
|
|
|
 |
|
 |
This is a very nice control, and was easy to setup and start using. I have a couple of questions about using this control as a tooltip, and I wonder if you have already done a similar project.
1. I was considering using this as a tooltip for a TreeView. I want to show a tooltip when hovering over each node. However, since a TreeNode is not a Control, and does not have a MouseLeave event, I tried to display the popup when the mouse is moved over the tree itself. This works to display the popup, but after the popup is visible the MouseMove event of the TreeView is no longer called. This makes it difficult to determine when to hide or redisplay the popup. Do you have any suggestions how to use this as a tooltip over a tree?
2. As a tooltip, it would be nice to have delay properties for display and redisplay like the ToolTip class. Have you given any thought to this?
|
|
|
|
 |
|
 |
Thank you, I am glad you like it.
1. Did you set FocusOnOpen property to false so the popup does not steal the focus? See the grid-example, I believe you want to achieve something similar.
2. Yes, time permitting I shall create a base class for tooltip.
Łukasz
|
|
|
|
 |
|
 |
After some testing, I was able to successfully create a custom tooltip over a treeview by using a Timer with the mouse events. The code looks something like this:
Class Variables
Popup toolTip;
CustomToolTip customToolTip;
Timer toolTipTimer = new Timer();
TreeNode toolTipNode = null;
Initialize Code
toolTip = new Popup(customToolTip = new CustomToolTip());
toolTip.AutoClose = false;
toolTip.FocusOnOpen = false;
toolTip.DropShadowEnabled = true;
toolTip.ShowingAnimation = toolTip.HidingAnimation = PopupAnimations.Blend;
toolTip.AutoSize = true;
toolTip.Resizable = true;
toolTipTimer.Interval = 1500;
toolTipTimer.Tick += new EventHandler(toolTipTimer_Tick);
tv.ShowNodeToolTips = false;
Events
int nStartX = 0; int nStartY = 0; int nLastX = 0; int nLastY = 0;
void toolTipTimer_Tick(object sender, EventArgs e)
{
if (toolTipNode != null)
{
toolTipTimer.Stop();
customToolTip.TipText = toolTipNode.Text.Trim();
toolTip.Show(this, nLastX + 10, nLastY + 50);
}
}
private void tv_MouseMove(object sender, MouseEventArgs e)
{
TreeNode node = tv.GetNodeAt(e.X, e.Y);
if (node == null)
{
toolTipTimer.Stop();
if (toolTip.Visible)
{
toolTip.Close();
}
}
else
{
if (!toolTipTimer.Enabled)
{
toolTipNode = node;
toolTipTimer.Start();
nStartX = nLastX;
nStartY = nLastY;
}
else if ((e.X < nStartX-5) || (e.X > nStartX+5) || (e.Y < nStartY-3) || (e.Y > nStartY+3))
{
toolTipTimer.Stop();
if (toolTip.Visible)
toolTip.Close();
}
}
nLastX = e.X;
nLastY = e.Y;
}
private void tv_MouseLeave(object sender, System.EventArgs e)
{
toolTipTimer.Stop();
toolTip.Close();
}
This works nice to keep the tooltip displayed until the mouse is moved again. I might try a second timer to close the tooltip after a delay.
|
|
|
|
 |