Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to position a control in a form?
Message
From
11/08/2007 12:05:05
 
 
To
11/08/2007 00:34:58
Czarina Joyce Villanueva
Innovision Systems International
Manila, Philippines
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
01247595
Message ID:
01247631
Views:
20
In any of the Key events (KeyUp, KeyDown, etc), you can find where the cursor is with this code:
int x = ((TextBox)sender).Cursor.HotSpot.X;
int y = ((TextBox)sender).Cursor.HotSpot.Y;
I suggest using a ContextMenu as your "Popup" window.
private void MyTextBox_KeyUp(object sender, KeyEventArgs e)
{
	if (e.KeyValue == 190)
	{
		int x = ((TextBox)sender).Cursor.HotSpot.X;
		int y = ((TextBox)sender).Cursor.HotSpot.Y;

		this.oContextMenu.Show((TextBox)sender, new Point(x+100, y+10));
	}
}
You'll have to play with the x,y coordinates.

The ContextMenu is set up elsewhere, like this:
this.oContextMenu.MenuItems.Add(new MenuItem("Number One"));
this.oContextMenu.MenuItems.Add(new MenuItem("Number Two"));
You can even set up a Popup event handler for the ContextMenu so the user can select an item.
this.oContextMenu.Popup += new System.EventHandler(this.oContextMenu_Popup);
.
.
.
private void oContextMenu_Popup(object sender, EventArgs e)
{
	// do something here with selection
}
~~Bonnie




>I have a text box set as multiline equivalent to editbox of VFP. I want to position a control say listbox where the cursor is located. My intention is to mimic intellisense feature of VS.Net where upon typing a period (.), a box with the control properties is displayed right at the position where the cursor is blinking.
>
>TIA.
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform