|
You can change the tab selection like this.
myTabControl.SelectedTab = myDepartmentTabPage
|
|
|
|
|
Thanks for this.
It seems to work fine if that particular form (with the department tab) is open already.
What I'm doing, from the menu item, is ....
Dim frmCompany As New Form CompanyDetails
frmCompany.ShowDialog()
How would I send your line of code at the same time as showing the dialog so that when the dialog opens, it opens on the Department tab?
-- modified at 16:32 Sunday 14th May, 2006
Hi - I just worked it out ....
Dim frmCompany As New Form CompanyDetails
frmCompany.TabControl1.SelectedIndex = 1
frmCompany.ShowDialog()
|
|
|
|
|
Do it in the load event of CompanyDetails form because it is not recommended to make your control modifier PUBLIC.
_mubashir
-- modified at 4:57 Monday 15th May, 2006
|
|
|
|
|
"_mubashir" is right. You should be setting the Tab focus in your form's Load event handler. That's where all form initialization is supposed to go.
|
|
|
|
|
OK - thanks for the feedback guys - but once I've actually opened the form, how does that form know which menu item triggered it - and so open the appropriate tab?
|
|
|
|
|
You should create a public method in your form class used to select which tab you want selected. I recommend that you create an enum that the calling code can use for the selection.
Public Class MyTabForm : Inherits Form
Public Enum TabSelect
Employees
Departments
End Enum
'
Public Sub SelectTab(tab As TabSelect)
If (tab = TabSelect.Employees) Then
myTabControl.SelectedTab = myEmployeeTabPage
Else If (tab = TabSelect.Departments) Then
myTabControl.SelectedTab = myDepartmentTabPage
End If
End Sub
End Class
Your calling code would then look like this.
Dim myForm As New MyTabForm
myForm.SelectTab(MyTabForm.TabSelect.Employees)
myForm.ShowDialog()
|
|
|
|
|
Thanks Joshua, this works well.
However, what I'm a little confused about (and please excuse my naivety - I've still got loads to learn yet!), is why is this better than my previous 'discovery' - which was basically a one-liner, as opposed to the extra lines of code that you've kindly suggested?
|
|
|
|
|
penguin5000 wrote: and please excuse my naivety - I've still got loads to learn yet!
No problem. There's always something new to learn. I'm learning something new all the time too. That's part of the fun in software development.
penguin5000 wrote: why is this better than my previous 'discovery'
Providing public access to your form's controls is considered bad practice. Why? Because if later down the road you want to...
- Use different controls to display the same info. (Like not a TabControl.)
- Change how you use your existing controls. (Ex: Change the tab order.)
...then you would have to update all of your form calling code too. This becomes a big issue if your app is huge and your form is called from several places.
The suggestion I provided allows you to change your form without effecting your calling code. That means less maintenance work in the future.
I hope this helps!
-- modified at 3:30 Friday 19th May, 2006
|
|
|
|
|
Thanks - yes, it does help. Its a bit of short term pain, for long term gain!
|
|
|
|
|
How i can draw an graph in Excel page if i insert it as ACTIVEX ?????????????
==> How i can implement the tab while i writing in excel page ???????????
=>how i can open excel file from code in micrsoft excel ????
all of these how can done inside the code ???????????? doh: :zz
|
|
|
|
|
hi all,
how can i create dsn runtime for sql server in vb.net.
pls help with code.
thanks
vipin paliwal
|
|
|
|
|
|
because i have many database in my sql server. these database are store different infromation for different company.
and most important part i don't know how many database user create in database. because i give the user facility.he can create many database in my database.
i want to dsn only for report because i not copy all the report for per database.
vipin paliwal
|
|
|
|
|
Hi, im dynamically creating an vb.net listbox at runtime and am trying to set the visibility of this
control at a later point using javascript. The listbox control is also added to the control list
of an <asp:panel>
heres the javascript code that im using
document.getElementById('imageList').style.visibility = 'visible';
it throws an "error:object required"
how do i access a dynamic control using javascript?
any help would be muchly appreciated
thanks
geoff
-- modified at 6:48 Sunday 14th May, 2006
|
|
|
|
|
You listbox has to have a ID, trough which you can acces it with getElement...
--------------------------------------------------------
My portfolio & development blog
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
this is how i added the object
Dim list As New ListBox
list.ID = "imageList"
panel.Controls.Add(list)
it broke on this line of code when i was trying to display it after i clicked on a link
document.getElementById('imageList').style.visibility = 'visible';
I think the error happened because the ListBox control exists on the control list for the panel and
not the main controls list, if thats correct how would i access this list from javascript..
and in turn set values on it etc..
any example code would be really helpfull or a point in the right direction.
-- modified at 9:40 Sunday 14th May, 2006
|
|
|
|
|
Check your HTML and see what is the actuall ID of the control.
--------------------------------------------------------
My portfolio & development blog
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
i checked the html and it isnt rendered this is because
list.Visible = "false" initially, this was so the control was hidden until a link was clicked.
when i set this value to true initially the javascript error doesn't get thrown.
i wanted this control to be hidden initially, and then set its visibility=true from
javascript once the link is clicked, is this at all possible?
ive tried sitting it inside a div setting the div's visibility to hidden but it just stretches the div
|
|
|
|
|
If you set the visiblity property to false then the control is not rendered at all hence you can not reference it.
You will have to add the display: none CSS style to the control and then change that trough javascript.
--------------------------------------------------------
My portfolio & development blog
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
exactly what i was after, thanks heaps
|
|
|
|
|
Can any of you guys advise what I'm doing wrong here? I'm new to this, so I'm just finding my way around the design view on the form.
I've filled two datasets on form load - one being Employees, and the other Departments.
I've got Employees and Departments on separate tabs on a form. The Departments are in a grid, and the Employees on a simple data form.
On the Employees tab, if I press Save, every field updates the MS Access table - except the combo box which is what I'm doing to select the employee department.
I've typed some entries, in Access, into the Department field in the tblStaff table - and these entries are being retrieved fine.
The datasource is 'objdsCompanyDetails.tblDepartments'
The datamember is 'DepartmentName'
... and this is correctly displaying my list of departments.
I've tried all sorts of combinations in the Binding section of the properties window, but I can't get this field to update the Access mdb file.
Help! Something so simple is driving me nuts!!
|
|
|
|
|
hello every body,
i want to save an image to a table in sql, but i cant do it.
please help me.
best regards.
ali.
Devil
software Engineer
|
|
|
|
|
|
I dont understand C#.NET please help me on VB.NET
thank you
Devil
software Engineer
|
|
|
|
|