How to close the PopUp window in TelerikRadGrid on save? - c#

I am using TelerikRadGrid in ASP.NET. When I press edit or add new, a new PopUp window appears, when I fill the data and save everything is OK, but the popup window stays.
So how can I save and close the window at the same time (I know how to save, but I don't know how to close the window after saving?)

Did you search the Telerik's forum? Popup Edit form not closing

When your page reloads after saving the data you need to put a JavaScript window.close()

Or programatically you can try:
protected void RadGrid1_ItemInserted(object sender, GridInsertedEventArgs e)
{
e.KeepInInsertMode = false;
}

Related

Can't Focus To Any Control after Closing Dialog

I am showing some database records in a Dialog. When I click any particular record that record fills to Active Form. But I want to focus to a button when my dialog close. So I have written the following code on form closing evennt.
private void frmDG_RecordSelection_FormClosing(object sender, FormClosingEventArgs e)
{
RecordSelectionStatus.Text = "False";
Form TargetForm = Home.ActiveMdiChild;
Button SelectRefConsultant = (Button)TargetForm.Controls.Find("btnSelectRefConsultant_NI", true).SingleOrDefault();
SelectRefConsultant.Focus();
TargetForm.ActiveControl = SelectRefConsultant;
}
But it's not working. Focus still remain to it's previous place. What am I missing ?
I am assuming that the dialog is modal... Instead of doing this in FormClosing do it, after calling ShowDialog(). If not, try using the FormClosed event instead.
I think your code is not working because, while the Form is closing, it still has modal focus.
If frmDG_RecordSelection is also MDIChild, then Home.ActiveMDIChild is this form. That is being closed.
But if frmDG is just a Dialog, the problem is different.
This dialog is Closing. But it's still visible. You cannot set focus to control that is not visible.
So you will have to set focus after this frmDG is completely closed, and invisible... To be more specific, when your MDI form is visible.
It's far more easier to do this from your MDI Form. I don't know how you have programmmed it, but I suppose it's something like that:
//this is in your MDI form
void OnRecordSelected(...)
{
frmDG yourDialog = new frmDG();
frmDG.ShowModal();
frmDG.Dispose();
}
In this case, you will have to set focus after frmDG is disposed.

How to get back the focus on popup, after losing it in WPF?

I have a main window, If I click a certain button, I have a popUp window, that pops up with few different component (input, button, dropdownlist etc) on it. Everything works fine, until I lose focus by simply clicking outside. And if I want to come back, I click back on Popup, but it can't be active again, and for that to be active, I have to click on the Main window, or to click on the appIcon on the taskBar.
Have you guys ever had such problem?
And How to resolve it?
Thank you!
I think you are looking for PreviewMouseDown event. I have tested it and it does recover lost focus.
private void Popup_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{
this.Focus();
}

Linking an option in the menustrip to an image similar to a MessageBox.Show

total newbie to C#, working on my final project for my intro class. Anyways, I am doing an online ordering form for a restaurant. In my menustrip, I have an option "Menu" (the actual restaurant's menu). I am going to scan a copy of the actual menu and import it into the resources, and when the user clicks "Menu", I'd like the picture to pop up similar to how a MessageBox does, and incorporate an "OK" button into it to exit. Is this possible?
private void viewFullMenuToolStripMenuItem_Click(object sender, EventArgs e)
{
???? PictureBox1 = Properties.Resources.Menu.jpg;
}
I know this is wrong. Any suggestions? Am I on the right track? Thank you!
Why not write your own form that has a PictureBox and a button at the bottom. Put OK text on the button and close the dialog once it is clicked
Here is the Picture Box
You would then set the Image property on the PictureBox.
PictureBox1.Image = Properties.Resources.Menu.jpg;

Show a tooltip on the Close (X) button on the form

I have a form, wherein I prohibit the user from closing it when the user clicks the Close (X) button. Is it possible to show a tooltip on the Close (X) button whenever it is clicked? I want to do it to notify the user why the form would not close.
I thought of a messagebox but then I thought it would be too annoying to close the messagebox every time you click the Close (X) button.
Is there a better way to notify the user, than what I'm trying to do?
EDIT:
This is my code for the FormClosing event
private void InputForm_FormClosing(object sender, FormClosingEventArgs e)
{
if (e.CloseReason == CloseReason.UserClosing)
{
e.Cancel = true;
if (!mCloseReason)
{
e.Cancel = false;
}
}
}
I have a method that will save the inputs in the form. Once that method is finished, I need to automatically close the form. The if-statement will be true once I call this.Close(), this means I can't close the form. That's why I used a variable called mCloseReason to be able to close the form automatically. Now, that's why I was asking if I can notify the user through a tooltip once the Close (X) button is clicked.
I believe the default tooltip for the close(X) button is not editable without some hacking (and it is not practical).
Maybe what you could do is have a status field below your form, so when the user clicks the close button, it says in the status field "cannot close form (...)"
Or another idea is to have a message pop up somewhere on the form and go away after a little, indicating the form cannot be closed.
Another good idea was mentioned by Roger... just have a Close button somewhere on the form with a tooltip coded to it, and hide the forms' title bar?

How to close Find window in a webbrowser control

I use a WebBrowser control and it's find functionality:
private void findToolStripMenuItem_Click(object sender, EventArgs e)
{
webBrowser1.Select();
SendKeys.Send("^f");
}
Which works fine. Only problem that there is a case when user can make WebBrowser unvisible to perform some other tasks:
webBrowser1.Visible = false;
But Find window remains visible. Any suggestions?
Thank you.
To close, try this
webBrowser1.Select();
SendKeys.Send("^f");
SendKeys.Send("{ESCAPE}");
There is no easy/direct way to control the Find dialog. One way to close the Find dialog is by sending "ESCAPE" to the dialog when it has focus. If you send "^f" prior to sending "ESCAPE", that will force the find dialog to get focus.

Categories

Resources