mdicontainer overlap the childcontrol - c#-4.0

In my application I have a main page with a menustrip to navigate to other forms Since i want it to be opened always I set it as a MDICONTAINER .now I need to open a form on menustripclick event as child i set the form like this
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
this.IsMdiContainer = true;
loginmain();
intialsetupform();
}
private void companyToolStripMenuItem_Click(object sender, EventArgs e)
{
Master.CompanyMasterForm cmpnymasterform = new Master.CompanyMasterForm();
cmpnymasterform.MdiParent= this ;
cmpnymasterform.Show();
}}
All was Ok and I got the childwindows work correctly
but Now i need to add two panels in the mainform << one for showing status meddages and other for showing some other controls
I had added the panel and anchored them and the issue is that now when the child window opens all the panels and controls of the parentform(mainform) comes above the childwindow controls which make it unreadable Please provide any ideas to overcome this

I had set the location of all the pannels using Anchor properties of the control now the controls know there location
and set the message box to bottom using dock property

Related

Dynamically Change Button Color

I have added a PXAction to a custom Graph extension class. This places a "button" at the top of the screen. I want to dynamically change the color of the button in code. How can I do that? Is it possible?
I am using version 19.100.0122
TIA!
Note that those types of changes are not allowed by Acumatica ISV Certification program.
You can use JavaScript to change the CSS styles. Add a JavaScript element anywhere that the customization project editor will allow you:
Fill in script properties, set it as a startup script and put the following JavaScript in the script property (you'll need to change "Test" to the display name of your Action):
function setActionButtonColor(){
var x = document.getElementsByClassName("toolsBtn");
var i;
for (i = 0; i < x.length; i++) {
// Replace "Test" by the display name of your action button
if (x[i].getAttribute("data-cmd") === "Test")
x[i].style.backgroundColor = "red";
}
}
In DataSource ClientEvents->CommandPerformed property you put the name of the JavaScript method to call (setActionButtonColor):
When opening the page JavaScript method is executed and changes the background color of the Action button:
I tested with this graph extension:
public class SOOrderEntry_Extension : PXGraphExtension<SOOrderEntry>
{
public PXAction<SOOrder> test;
[PXUIField(DisplayName = "Test")]
public virtual IEnumerable Test(PXAdapter adapter)
{
return adapter.Get();
}
}

close a ContentDialog after LostFocus on it and click on the MainPage Interface

I have used a ContentDialog to create a PopUp ContentDialog like the one in the Groove App:
the problem is that,I can't close it when I click on any part of the MainPage Interface and loose focus,I have tried like this,but it doesn't work :(,it closes only after I send data from the ContentDialog
MainPage.xaml:
private void MenuButton_Click(object sender, RoutedEventArgs e)
{
AddFavoris formTask = new AddFavoris();
t = formTask.ShowAsync();
string f = formTask.Opgave;
formTask.LostFocus += new RoutedEventHandler(formTask_LostFocus);
}
private void formTask_LostFocus(object sender, RoutedEventArgs e)
{
t.Cancel();
}
so,is there any solutions can I use to have a ContrentDialog that will be closed after a Click on the MainPage interface and lost focus on it
thanks for help
Use Flyout instead of using a ContentDialog. Flyouts can be dismissed by tapping or clicking somewhere outside the flyout.
For more information: Guidelines for flyouts, Guidelines for dialog controls

How to close user control used in radgrid filtering?

I have a radgrid, for date column i have created a custom user control for filtering. I need to create a close button to close the user control. There are no close events which i can call. I don't want to make visibility collapsed. I started with something below:
public partial class DateFilterControl : UserControl, IFilteringControl
{
public event CloseEventHandler Close;
public delegate void CloseEventHandler();
private void Button_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
}
It is throwing nullreference exception which is obvious to come. What code do i need to put to close the user control?
use Messaging Service. With this you can close the window in ViewModel so no need to give close function in Backend. Add Command property to Cancel button
<Button Content="Cancel" Command="{Binding CancelCommand}"/>
Now in the ViewModel add the RelayCommand property in that add
Messenger.Default.Send<bool>(true, typeof(XViewModel));
Now in the BackEnd of this userControl adds following in the constructor.
Messenger.Default.Register<bool>(this, typeof(ScheduleViewModel), (b) =>
{
if (b == true)
{
this.DialogResult = true;
}
});
Now u can close the Window...
This will surely helps u...

Extend View and Custom Dialogs

I am working on a game where I am extending the view and performing operations in the class. I need to have a popup in the game which will have 3 buttons inside it. I have managed to have the popup show-up using custom dialogs but when I configure the onClick as follows:
private void popUp() {
Context mContext = getContext();
Dialog dialog = new Dialog(mContext);
dialog.setContentView(R.layout.custom_fullimage_dialog);
dialog.setTitle("Cheese Market");
Button one = (Button)findViewById(R.id.firstpack);
one.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
cheeseLeft = cheeseLeft + 10;
masterMoveLock = false;
return;
}
});
}
It force closes giving a nullpointerexeption even though it is defined in the custom_fullimage_dialog layout.
Can someone help me figure out how to have the button click detected in this scenario?
Thank you.
Try calling dialog.findViewById instead.
You're setting the contentView for the dialog, but by calling findViewById you're looking for it under your activity's content view.

Fire parent click event when child is clicked in windows form user control

I have a user control
public partial class ButtonControl : UserControl
which has two controls of label and picturebox
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.text = new System.Windows.Forms.Label();
I have used this control in a windows form
this.appointmentButton = new DentalSoft.UI.Controls.ButtonControl();
created an event
this.appointmentButton.Click += new System.EventHandler(this.appointmentButton_Click);
but the problem is, if i click on the image or the label inside of the control, the click event doesn't fire.
I want to fire this click event no matter where the user clicks inside of the control. Is it possible?
Yes it is a simple matter. When you click on the child controls they receive the click event and the user control does not. So you can subscribe to the child control click events and when they occur simply raise the usercontrol click event and it will appear to click no matter where the mouse is positioned.
Just double click on the picturebox and the label to create the click event handlers then add a line of code to call the parent usercontrol OnClick method.
private void text_Click(object sender, EventArgs e)
{
this.OnClick(new EventArgs());
}
private void pictureBox1_Click(object sender, EventArgs e)
{
this.OnClick(new EventArgs());
}
I solved this problem the following way. I wanted to changes the background images of the parent PictureBox when the child Label was clicked. I played around some and found I could call the event handler in the following way.
private void Label_Click(object sender, EventArgs e)
{
Label label = (Label)sender;
Box_Click(label.Parent, e);
}
private void Box_Click(object sender, EventArgs e)
{
//
PictureBox box = sender as PictureBox;
//
if (isMine[int.Parse(box.Name)])
{
box.Image = Image.FromFile(#"..\..\images\BoxRedX.jpg");
MessageBox.Show("Game Over");
}
else
{
box.Image = Image.FromFile(#"..\..\images\BoxGray.jpg");
}
}
As you can see I grab the Child and using it to reference its parent and send it to the parents click event. This is the code I used to work in my project. The important method is the first on listed. The second is there for clarity to see how it passed and worked.

Resources