-
Jun 5th, 2015, 07:28 AM
#1
Thread Starter
New Member
which event of form that makes contrlos on it updated
i have 2 form in:
form1 :
combobox that show values form 1 to 4 when i choose for ex 3 then in
form2:
show 3 textboxes that was not visible before depend on choosing value on combobox on form1
my qus is :
when i choose for ex 3 on combobox then go to form 2 i see the 3 textboxes
but
when i return and change the vlue of combobox to for ex 2 the textboxes on form2 remain 3 ??
so any idea or where do i put the code in form event for ex form load ... also i dont want to close form2 when i return to form1 just i hide it to keep any thing wirtten on it
For S As Integer = 0 To Form1.cbox1.SelectedIndex
newbox(S).Visible = True
Next
thanks for any idea or example
-
Jun 5th, 2015, 07:37 AM
#2
Hyperactive Member
Re: which event of form that makes contrlos on it updated
why dont you want to close the form?
also the shown event would proberbly be best for what your describing
-
Jun 5th, 2015, 11:24 AM
#3
Thread Starter
New Member
Re: which event of form that makes contrlos on it updated
becasue there is data will be written in textboxes on form2 so if it closed that data will be erased
-
Jun 5th, 2015, 11:55 AM
#4
Re: which event of form that makes contrlos on it updated
I would create a public sub in form2 and pass the number of textboxes to show in it. Then call that sub from form1.
In Form2
Code:
Public sub updateTextBoxes(n as integer)
For S As Integer = 0 To Form1.cbox1.SelectedIndex
newbox(S).Visible = True
Next
End Sub
then from form1 when you want to update...
Code:
Form2.updateTextBoxes(numberToShow)
Process control doesn't give you good quality, it gives you consistent quality.
Good quality comes from consistently doing the right things.
Vague general questions have vague general answers. A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.
______________________________ Last edited by kebo : Now. Reason: superfluous typo's
-
Jun 5th, 2015, 12:46 PM
#5
Re: which event of form that makes contrlos on it updated
Originally Posted by bazaleem
when i choose for ex 3 on combobox then go to form 2 i see the 3 textboxes
but
when i return and change the vlue of combobox to for ex 2 the textboxes on form2 remain 3 ??
so any idea or where do i put the code in form event for ex form load ... also i dont want to close form2 when i return to form1 just i hide it to keep any thing wirtten on it
For S As Integer = 0 To Form1.cbox1.SelectedIndex
newbox(S).Visible = True
Next
thanks for any idea or example
When you change the combo selection the SelectedIndexChanged event is raised, there you'd call your code. I'd probably create a public sub or property on that secondary form and pass it the index, , something like,..
Main form
Code:
Private Sub ComboBox1_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
If secondaryFormInstance IsNot Nothing Then
secondaryFormInstance.VisibleTextBoxes = ComboBox1.SelectedIndex
End If
End Sub
Secondary form
Code:
Public Class Form2
' a list to hold textboxes on this form we want to hide/show
Private textBoxes As New List(Of TextBox)
Private Sub Form2_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
' Add textboxes on this form to the list.
textBoxes.AddRange({TextBox1, TextBox2, TextBox3})
' Hide all the textboxes in list.
VisibleTextBoxes = -1
End Sub
' Property: Set range of textboxes visible & hide remaining.
Private _VisibleTextBoxes As Integer = -1
Public Property VisibleTextBoxes() As Integer
Get
Return _VisibleTextBoxes
End Get
Set(ByVal value As Integer)
_VisibleTextBoxes = value
For n = 0 To textBoxes.Count - 1
textBoxes(n).Visible = (n <= value)
Next
End Set
End Property
End Class
Last edited by Edgemeal; Jun 5th, 2015 at 07:55 PM.
-
Jun 5th, 2015, 01:55 PM
#6
Thread Starter
New Member
Re: which event of form that makes contrlos on it updated
thanks kebo i tried your code it didnt work for me but thaaaanks
Edgemeal
thanks for help it works like a charm ^^^^^
-
Jun 5th, 2015, 01:58 PM
#7
Re: which event of form that makes contrlos on it updated
Yea, sorry... it should have been
Code:
Public sub updateTextBoxes(n as integer)
For S As Integer = 0 To n-1
newbox(S).Visible = True
Next
End Sub
That's what happens with a blind cut and paste of the code.
Process control doesn't give you good quality, it gives you consistent quality.
Good quality comes from consistently doing the right things.
Vague general questions have vague general answers. A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.
______________________________ Last edited by kebo : Now. Reason: superfluous typo's
-
Jun 7th, 2015, 07:32 AM
#8
Thread Starter
New Member
Re: which event of form that makes contrlos on it updated
Originally Posted by kebo
Yea, sorry... it should have been
Code:
Public sub updateTextBoxes(n as integer)
For S As Integer = 0 To n-1
newbox(S).Visible = True
Next
End Sub
That's what happens with a blind cut and paste of the code.
thank u kebo
i go back and use simple thing Edgemeal give it to me that thing should be :
"When you change the combo selection the SelectedIndexChanged event is raised, there you'd call your code"
this slove my problem and many problem i dont focus on it before
also code he puts is working good
i appreciate your help my friend thanks
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
|