I have a Mdi parent container and i am using menu item to open child forms in MDI Parent Form.
Here is the code for opening the child form
Dim childform1 as new Form3
childform1.MDIParent = me
childform1.show()
The above code is working fine. The problem is with the startup position of the child form. i.e. child form doesn't open at required position(just right below the menubar) instead it opens at position randomly. like sometimes near the required position and other times where it wishes.. lol is there any standard way to position it. I tried MDI Child Form Start Position Problem answer by calculating and its positioned near by where i want. But I want to look for a standard way for doing this.
This should do it:
childform1.location = new point(x, y)
Inside the childform, you can add this:
Me.StartPosition = FormStartPosition.Manual
Then you can set location before saying childform1.show()
Related
I have on the MDIparent a Save button. My issue is I am on one of the child forms and have filled in all data in textboxes and then I would click the SAVE button on top of my MDI parent. That button checks what is the activechild and calls routine on the form to Insert/Update records in database.
But when I click the save button in debug I see if find the correct child form and code goes where I would it to but all the Txtboxes.text are = ""
Here is the code on the button on MDIParent form.
Select Case Me.ActiveMdiChild.Name
Case "frm1"
frm1.btnSave_Click(sender, e)
End Select
When the case is matched and goes back to frm1 none of the textboxes have values.
I know I am missing something.. any help
Can't find how to get new window (form) which will behave like "Find and replace" window in VB IDE 2008, where window is allways on top and I can work on it but I can also work with underlayed code bit find and replace don't hide when I set focus to code window.
The best solution will be if I would be oopen more than one such window.
This is how I try but opened window is modal!
Dim fl As New myWindow
With fl
.StartPosition = FormStartPosition.Manual
.aCallerLocation = Me.Location
End With
Dim ret As Integer = fl.ShowDialog(Me)
fl.Close()
fl = Nothing
Showing the form as a dialog form, is not necessary to make the form stay in front of the primary form. Using the ShowDialog method causes the form to be modal. What makes it stay in front is the fact that you are passing Me for the owner parameter. You can still pass an owner form, even if you are just calling the non-modal Show method:
Dim fl As New myWindow()
' ...
fl.Show(Me)
That way, the new form will stay in front of the primary form, but it will not be modal. Therefore, both forms will be usable and you can show as many of those non-modal child forms in front of the primary form as you like.
I have a bit of a weird issue. We use DevExpress controls to do all our Windows Form development. Anyway, I found a perfect use for the DataRow.SetParentRow/GetParentRow methods in my grid. So I created a DataRelation, added it to the DataSet and bound it as the data source for my grid. The issue is I now find this:
On my grid. It seems to be the DataRelation (when I mouse over it the tooltip is the DataRelation name).
Does anyone know how to hide this line of controls? If I cannot get rid of them I will have to write a parent/child link between the rows, and that would be a shame because the DataRelation stuff works almost perfectly.
Thanks in advance!
You want to set the following property to hide those: (this is for a grid view, banded grid view or advanced banded grid view)
In OptionsDetail set EnableMasterViewMode=False
If you have a master Detail grid that has times where the details are empty and you want to hide those you can do so by handling the custom draw for the masterview cells something like this:
Private Sub gvMain_CustomDrawCell(ByVal sender As Object, ByVal e As DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs) Handles gvMain.CustomDrawCell
Dim View As DevExpress.XtraGrid.Views.Grid.GridView = CType(sender, DevExpress.XtraGrid.Views.Grid.GridView)
If e.Column.VisibleIndex = 0 And View.IsMasterRowEmpty(e.RowHandle) Then
CType(e.Cell, DevExpress.XtraGrid.Views.Grid.ViewInfo.GridCellInfo).CellButtonRect = Rectangle.Empty
End If
End Sub
How to make a form always stay on top of another form.
Also both form's enabled property must be true
I don't wanna make use of topmost property.
Edit 1 :
Another similar question in C# says you can use Form.Owner Property to do the trick , how to make use of this property ?
Edit 2 : The Owner Property works fine untill I try to open it the second time.
This is the error message I get
I believe you need the frm.ShowDialog() instead of frm.Show()
frm is the other form you need to show over your current form and instead of using Show, this will make it as a dialog form over your current form (however you won't be able to select the parent form or the form behind it unless you close the frm form
EDIT
To enable edit on both forms
Form2 frm = new Form2();
frm.Owner = this;
frm.Show();
Hope this helps you out.
I have 3 forms, one frmMain - main form, second is frmUserType- childform, and the last frmCreateUserType. In the main form I have a menu item to open my frmUserType, In this form I have a button to open another form which is my frmCreateUserType, In this form I have a button to add records then update the listview in frmUserType. The problem is the listview will not access with my add button control in frmCreateUserType. I tried not to used mdiparent declaration for my frmMain and frmUserType as children and it works, so meaning that the problem is showing my frmUserType as childform?I am using vb.net 2008
Any suggestion would greatly appreciated
Thans in advance
Code to open my second form (frmUserType)
Dim frmChildUserType As New frmUserType
frmChildUserType.MdiParent = Me
frmChildUserType.WindowState = FormWindowState.Maximized
frmChildUserType.Show()
Code for my add button to update the listview in frmUserType
frmUserType.lsvUserType.Items.Clear()
FillListViewUserType("SELECT * FROM pr_user_type", frmUserType.lsvUserType)
You're creating a new instance as:
Dim frmChildUserType As New frmUserType
But in your code:
frmUserType.lsvUserType.Items.Clear()
FillListViewUserType("SELECT * FROM pr_user_type", frmUserType.lsvUserType)
You're not accessing that instance but is instead using the default instance of frmUserType. So I think you're updating a different instance of the ListView than what you think.
If you change your code to instead be:
frmChildUserType.lsvUserType.Items.Clear()
FillListViewUserType("SELECT * FROM pr_user_type", frmChildUserType.lsvUserType)
I think it would work as you expect.
If you don't know what a default instance is, you can find a blog about them here (I think they're a bad idea).