Where I Right-Click on GridColumn To Popup the GridColumn Menu
It Pops up with the main Popup menu
Your problem appears to be caused by PopupMenu being called all over regardless of the location of the mouse.
Use event "PopupMenuShowing" to display the user menu in GridControl. You can implement this event to decide whether to display pop-ups based on the location of your mouse.
private void gridview1_PopupMenuShowing(object sender, PoupMenuShowingEventArgs e)
{
// check in row and in cell
if(!e.HitInfo.InRow && !e.HitInfo.InRowCell)
return;
// showing main(user) popup menu
popupMenu1.ShowPopup(gridcontrol1.PointToScreen(new Point(e.Point.X, e.Point.Y)));
}
Related
I have a popup window which is opened, and then within that popup the user can drag an item (from within the popup) which starts a DragDrop.DoDragDrop();
How can I have the popup automatically close when the users cursor leaves the Popup window?
I've tried a few options such as MouseEnter/Leave events and IsMouseOver properties, but none of these work as I believe the DragDrop initiates mouse capture.
This will work:
popup.Child.MouseLeave += (u, l) => popup.IsOpen = false;
By default, I need to focus on another component (a button or a textBox) to unfocus from the current one.
I want to just click outside.
So for example if I click on a textBox and write something, than click outside the TextBox, I shouldn't be able to type because the component is unfocused.
(I hope my explanation is clear, if not, please say so in the comments)
You can achieve this functionality by attaching to PreviewMouseDown event of a Window. Also in order to Lose Focus you need another focusable control (e.g. a text box named _dummyControl) to move focus to.
public MainWindow()
{
this.PreviewMouseDown += PreviewMouseDownEventHandler;
}
private void PreviewMouseDownEventHandler(object sender, MouseButtonEventArgs e)
{
//check conditions here...
_dummyControl.Focus();
}
more info:
PreviewMouseDown event occurs just before a MouseDown or click event occurs. By attaching to this event your code can tell when user clicks on the window and at that time you should move focus to a hidden control to simulate unfocus functionality.
Is there a way to add a label or content to a panel/groupbox once a button has been clicked ?
So for instance, lets say I wrote some content in the above textbox and I hit Post button. Is there a way to add this content in the below panel/groupbox ? And if I can't add to a panel/groupbox, which tool should I use ?
How to Display content from a TextBox when Clicked.
Please check on your MSVC under Solution Properties for all the Buttons, Text and Panels properties. Example; Button1, TextBox1 etc. Then make functions calls and assignments by these reference.
protected void Button1_Click(object sender, EventArgs e)
{
MessageBox.Show(" "+ TextBox1.Text);
}
This will display your content to a Pop up window. You can also try TextBox1.Content instead of TextBox1.Text.
NB: This code should be placed on your POST button.
I have the following window:
When I click outside the data grid, there is still something selected, it just grays out when I change tabs and come back:
I wanted to deselect the items when clicked outside the datagrid, but this gives me a problem, since the Change button is outside, it deselects everything and there is nothing more to change and my Command changes the button state do disabled:
I did this with a simple TargetedTriggerAction, but I can't make it work in such a way that it only fires when clicked outside the datagrid AND outside the Button. I tried to make a GotFocus on the grid inside the tab, but it doesn't fires, it only fires in the tab item or the tab control and basically fires everywhere when tied to it.
My structure is: Window -> DockPanel -> TabControl -> TabItem -> Grid (Stack panel for the buttons) (Datagrid)
My TargetedTriggerAction:
public class TargetedTriggerActionDataGridUnselect : TargetedTriggerAction<DataGrid>
{
protected override void Invoke(object parameter)
{
this.Target.UnselectAll();
}
}
I have a Winform Applicaion useing an MDI Form. On the MDI Form I have a ToolStrip with buttons (Buttons have images) on it acting as the main menu buttons for the application. So when user clicks on a button on the toolstrip the mdichild form for that button opens the child form.
So I have six buttons with images already created and in the project. But I want the user to select the buttons they want to appear on the toolstrip.
So the user opens the application and there is only one button on the toolstrip. The user clicks on that button and a child screen opens showing all the available existing buttons that could be on the toolstrip. The user selects the buttons they want to appear on the toolstrip then clicks that save button on the child screen.
What I want is that as soon as the user clicks that save button the buttons that the user selected should automatically appear on the toolstrip.
Right now I have to have the user close the applicaiton then reopen it for the buttons they selected to appear on the toolstrip.
How so I get the buttons to appear automatically?
Just create all of the ToolStripButtons, and set each one's Visible property to false. When the user picks them to be shown, change the Visible property of the ToolStripButton to true. They'll automatically appear on the ToolStrip.
I tested using VS2010 with Oxygene from RemObjects (formerly AKA Delphi Prism).
Start a new WinForms application
Drop a ToolStrip on the window. Right-click it and choose Insert standard items.
Double-click the New button (newToolStripButton, the one on the left end), and add the following code to the newToolStripButton_Click handler:
// Oxygene version: helpToolStripButton.Visible := not helpToolStripButton.Visible;
helpToolStripButton.Visible != helpToolStripButton.Visible;
Run the application, and click the newTooStripButton repeatedly, and watch the right-most ToolStripButton (the Help button) appear and disappear from the ToolStrip.
You can create any ToolStrip and add it to a MenuStrip.DropDownItems.Add.
The click EventHandler must be a (s,e) function.
ToolStripMenuItem ts = new ToolStripMenuItem();
ts.Name = $"MyMenuStrip";
ts.Text = "New MenuStrip";
ts.Click += new EventHandler(this.ToolStripMenuItem_Click);
private void ToolStripMenuItem_Click(object sender, EventArgs e)
{
ToolStripMenuItem clickedMenuItem = sender as ToolStripMenuItem;
Trace.WriteLine($"Clicked: {clickedMenuItem.Text}");
}