form containing user control not hiding - c#-4.0

I am facing some form hiding problem.
Actually I have a form with a user control on it. the user control has submit button, and when I click it I want the user control as well as the form containing it to be vanished.
I can use this.hide(), but it is only hiding the user control and not the form.
I create a
form1 f1 = new form1();
f1.hide();
and even tried
f1.close(),
but nothing is working.
Please help
EDIT:
this is the actual code:
Input inp = new Input();
inp.Show();
it is where the call the input form. In its loading event, I call the usinput user control.
USinput usinp = new USinput();
then in the submit button in the user control, the use the following code:
Input inpt = new Input();
inpt.Hide();
this.Hide();
Companies co = new Companies();
co.Show();
It shows the new form and the user control is gone, but the input form is still there.

Have you tried with that code only?
Have you made sure that your control isn't called f1 and has no name conflict?
Is your control class name form1?
It is definitly something around that.
EDIT:
Your problem is on the first line here.
Input inpt = new Input();
inpt.Hide();
this.Hide();
Companies co = new Companies();
co.Show();
In your UserControl, you create a new form. So you have 2 forms! The second one is never made visible though. You have to send to the UserControl a reference to the form. That way, you always use the same form.
Here's how to create the UserControl from the form:
USinput usinp = new USinput(this); //Will send a reference of the form to the control
The constructor of your control will look like this:
private Form parentForm;
public USinput(Input parentForm)
{
this.parentForm = parentForm;
}
And your submit button code will contain this:
parentForm.hide();

Related

TestFx - How to test validation dialogs with no ids

I have an application with grid of records and button insert. After clicking insert, there is a form, where you fill in data and click Ok for adding new record to the grid. After clicking Ok, there is validation which fires dialog with error informations, if any of the text fields do not match validation rules. Is there any posible way to test text on the dialog with textFx, if the dialog has no id?
This is an example for Alert based dialog:
In your test:
alert_dialog_has_header_and_content(
"Removing 'Almaty' location", "Are you sure to remove this record?");
In you helper test class:
public void alert_dialog_has_header_and_content(final String expectedHeader, final String expectedContent) {
final javafx.stage.Stage actualAlertDialog = getTopModalStage();
assertNotNull(actualAlertDialog);
final DialogPane dialogPane = (DialogPane) actualAlertDialog.getScene().getRoot();
assertEquals(expectedHeader, dialogPane.getHeaderText());
assertEquals(expectedContent, dialogPane.getContentText());
}
private javafx.stage.Stage getTopModalStage() {
// Get a list of windows but ordered from top[0] to bottom[n] ones.
// It is needed to get the first found modal window.
final List<Window> allWindows = new ArrayList<>(robot.robotContext().getWindowFinder().listWindows());
Collections.reverse(allWindows);
return (javafx.stage.Stage) allWindows
.stream()
.filter(window -> window instanceof javafx.stage.Stage)
.filter(window -> ((javafx.stage.Stage) window).getModality() == Modality.APPLICATION_MODAL)
.findFirst()
.orElse(null);
}
I know this issue is a little old and probably got fixed, but for documentation purpose in case someone else look for a fix for an issue alike, I see dialog.getDialogPane() in Dialog documentation, which would help lookup for specific controls inside the pane. So further on #plaidshirt query, we could retrieve buttons and input fields with:
dialog.getDialogPane().lookupAll()
Then narrow that down to buttons and input fields for example.

beforePageLoad failing when a view column is computed

I've got a view control which opens an xpage. When the xpage opens, the beforePageLoad event fires. It checks to see if there are any attachments in a particular field of the document being opened and if there are, it returns list of the filenames. This was working fine. Then, I was asked to change what's displayed in one of the columns of the view. I added a variable to the view control's data section to access the row. I then added some javascript to the column to display the data differently. That worked and it displayed the data as wanted. However, when I now click on the link to open the xpage, when the beforePageLoad event fires, the code that's there now fails. It fails with this error at the starred line:
Script interpreter error, line=9, col=49: 'closureField' is null at
[/Function_ReturnListOfClosureAttachmentNames.jss].ReturnListOfClosureAttachmentNames(CCEB1351591847CB85257E7C005EF68C)
function ReturnListOfClosureAttachmentNames(ltDoc ){
var closureAttachmentFileNames = "";
var thisLT = ltDoc;
var closureField:NotesRichTextItem = thisLT.getFirstItem("closeAttachments");
*>>> var eos:java.util.Vector = closureField.getEmbeddedObjects();<<<
var eosi:java.util.Iterator = eos.iterator();
while (eosi.hasNext()) {
var eo:NotesEmbeddedObject = eosi.next();
closureAttachmentFileNames = closureAttachmentFileNames +","+eo.getName();
}
return closureAttachmentFileNames;
}
I call this function from the beforePageLoad event and pass it currentDocument.getDocument(). I think I might have lost the document context after changing the column display data from 'view column' to 'computed value' but I'm not sure. Any ideas would be appreciated.
thanks!
Clem
Figured it out: When I assigned a variable to the view, when you click on a linked column in that view, it loads the current ViewEntry into the context and not a current document. So I put the unid of the doc from the selected ViewEntry in an application scope variable and returned it to the Document Id property when I open the xPage. I have to now update all my views but there aren't too many luckily. Thanks for working through this with me!
Clem –

Dynamically Selection of items in combobox

i want to add some functionality in combo box. I want that it should behave like Google's Search Box. Like i have added items in combo box from a database Say Name of the Doctors.
i want that as user type name of the doctor or first letter of the name of the doctor, the selection bar goes automatically only to related names.
Any suggestion friends???
try AutoCompleteMode of combobox, something like this:
сomboBox.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
сomboBox.AutoCompleteSource = AutoCompleteSource.CustomSource;
comboBox.AutoCompleteCustomSource = MyStringData();
where myStringData is :
public AutoCompleteStringCollection MyStringData()
{
var collection= new AutoCompleteStringCollection();
//you can add names of the doctors retrieved from the database here
collection.Add("one");
collection.Add("two");
collection.Add("three");
collection.Add("four");
return collection;
}
this would suggest those items which begins with those you typed.
If you want to show selection (highlighting) as you type, you can be a little more creative and create a simple combination of a textbox and gridView, which gets bound everytime TextChanged happens on the textBox

How to prevent a user from changing the selected row in an EditorGrid

Is there a way that I can prevent a user from changing the selected row? I was looking for something like a selectedRowChanging event that would either prevent or allow user from selecting a new row.
Kinda depends on how you have things set up...
I have a Grid to which I've added a CheckColumnConfig and RowEditor It's really a window into some DataBase tables. The user can modify any column 'except' the key columns. The user may also Add a new row. I defined 2 ColumConfigs. The EditColumnConfig has the various fileds disabled (i.e. if (column = keyColumn) {textField.disabled(); } the AddColumnConfig has all columns enabled.
Now if the user clicks the checkBox on a row and clicks an 'Add' button I reconfigure the grid with the addColumnModel : rowDataGrid.reconfigure(listStore, addStateColumnModel); When the user clicks the RowEditor 'Save' button I erconfigure the grid back : rowDataGrid.reconfigure(listStore, editStateColumnModel);
I 'spose you could define an uneditable ColumnConfig and swap it in and out. (or... catch the RowEditor 'BeforeEdit' event and disable to row).
That's an idea anyway... hope this helps.
grid.addListener(Events.BeforeEdit, new Listener<GridEvent<MyModel>>(){
#Override
public void handleEvent(GridEvent<MyModel> be) {
//This retrieves the model being edited.
MyModel model = be.getModel();
if (I do not want to edit this model){
be.setCancelled(true);
}
}
});

UserControl that embeds another user control, how to access embedded form fields?

I have a long form that the user has to fill out.
So I broke the form into logical units and created another user control for some elements (they will be reused elsewhere).
So say the form has these fields:
UserControl3.ascx
Username
password
email -- usercontrol2.ascx
address -- usercontrol2.ascx
city -- usercontrol2.ascx
state -- usercontrol2.ascx
So now in the codebehidn of usercontrol3.ascx, how will I access the usercontrol2.ascx's fields so I can write to the db?
Something like this works, but it is just not elegant:
Dim txtBox as TextBox = Ctype(parentControl.Controls(Index), System.Web.UI.Controls.TextBox)
stringVariable = txtBox.Text
The correct way to do it is to implement properties for your parentControl that access child's controls properties.
Public Property AddressField() as string
Set(byval value as string)
txtAddressField.Text = value
End Set
Get
Return txtAddressField.Text
End Get
End Property
if user control 3 contains user control 2, I would modify the code for user control 2 to expose public properties for the information that you need to retreive.
edit
There are other ways of doing it, but the property route is the safest route, and avoids strong dependencies between the two controls.

Resources