|
-
Feb 19th, 2010, 03:08 PM
#4
Addicted Member
Re: Add Buttons to panel, button/tab references, create/destroy entire tabs/layouts
 Originally Posted by korsen
I need to know how to have a button on a tab to create another button on a second tab that contains a panel, with appropriate spacing, the same size as other buttons already present, and the name of the tab that generated this new button as the text on the newly created button. I.e. button1 on tab1 will create and place a new button on a panel in tab2 that already has a grid of buttons (maybe 3x10 buttons) which will be placed underneath a particular column with the text tab2 on the new button which can also refer back to that tab automatically. Hopefully we can get all this code under a single button event.
Why create the button, why not show it when you need it and assign text to it. If you need it to do a particular process based on it's text, then handle that in the click event of the button.
 Originally Posted by korsen
I also don't know how to have a button on tab1 that focuses on tab2, which sets the back button on tab2 with a reference to go back to tab1 in order to remain dynamic. I.e. clicking on tab1's button will go to tab2 and set the back button there with a link back to the tab it was referred from.
I am not sure why you need to create your own navigation system for the Tab Control. The TabControl does a very good job of switching tabs by itself.
 Originally Posted by korsen
I'd also like to know if there's an easy way to create and destroy tabs with a specific layout. I.e. We have home tab, and comment tab. (This is for the sake of argument) On the comment tab1 (which contains all posted comments), we have a new comment button which creates a comment tab2 (or a dialog box for that matter) with appropriate textboxes, labels, and buttons in the right places which could also make use of the issues I posted above. So the new comment button on the comment tab1 will create either a new comment tab2 with appropriate objects, or a dialog box with the same, and then the submit button on this comment tab2 or box will create a new textfield/buttons on the panel containing the grid of buttons with the information provided in the fields from comment tab2/dialog box which is then destroyed.
Why create and destroy tabs, seems like a lot of overhead. Either show or don't show relevant tabs. A dialog box would probably be your best bet to get information to enter. I would create your own dialog box with public properties then pull your values from the properties of the instance of the dialog box. For example, here my own dialog box has a textbox, checkbox, and a numericupdown.
Code:
Public Class MyOwnDialogWithPropertiesToReturn
Public ReadOnly Property MyOwnAge() As Decimal
Get
Return Me.NumericUpDown1.Value
End Get
End Property
Public ReadOnly Property MyOwnName() As String
Get
Return TextBox1.Text
End Get
End Property
Public ReadOnly Property MyOwnFun() As Boolean
Get
Return CheckBox1.Checked
End Get
End Property
Private ReadOnly Property IsFormValid() As Boolean
Get
Return (Not String.IsNullOrEmpty(TextBox1.Text.Trim()))
End Get
End Property
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If Me.IsFormValid Then
Me.DialogResult = Windows.Forms.DialogResult.OK
Me.Close()
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.DialogResult = Windows.Forms.DialogResult.Cancel
Me.Close()
End Sub
End Class
And on my form I make the instance of myown dialog and then refer to the properties to get information back from the dialog.
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim frm As New MyOwnDialogWithPropertiesToReturn
Dim Aging As Decimal = frm.MyOwnAge
Dim Naming As String = frm.MyOwnName
Dim HavingFun As Boolean = frm.MyOwnFun
'get values
If frm.ShowDialog() = Windows.Forms.DialogResult.OK Then
Aging = frm.MyOwnAge
Naming = frm.MyOwnName
HavingFun = frm.MyOwnFun
End If
End Sub
 Originally Posted by korsen
I hope i haven't made the examples too confusing, but I can't figure out how to even make progress in these directions. Trying either fails completely, or semi-fails in getting these examples to function 100%.
It is kind of confusing what you want to do. If you could post some code it would help a lot or a screen shot or two of what you want, code would be best though.
If someone has helped you, please make sure to rate them. 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|