473,462 Members | 1,350 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

forms

I have 2 forms.
Form1 has two buttons.
When i click button1 i would like form2 to open and show
some objects on the form as visible.
If i click button2 i would like to set these objects
visible to false.

Can somebody tell me how i would do this using c#.

Maybe i can try using a boolean

thyanks
adam
Jul 21 '05 #1
3 1700
Place the second form inside a panel control and add a button to your page.
Set the panel's visibility to false at design time.

When the button is clicked change the panel's visibilty to true.

On the second button , set the panel's visibilty to false.

"adam" <ad********@go.com> wrote in message
news:04****************************@phx.gbl...
I have 2 forms.
Form1 has two buttons.
When i click button1 i would like form2 to open and show
some objects on the form as visible.
If i click button2 i would like to set these objects
visible to false.

Can somebody tell me how i would do this using c#.

Maybe i can try using a boolean

thyanks
adam

Jul 21 '05 #2
Hi,

You can try using the following code.....

This is assuming that you have another form in the same
application with the name Form2.

Imports System.Data

Public Class Form1
Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

Private m_objForm As Form2
Private m_blnFormVisible As Boolean

Public Sub New()
MyBase.New()

'This call is required by the Windows Form
Designer.
InitializeComponent()

'Add any initialization after the
InitializeComponent() call
m_objForm = New Form2()
m_blnFormVisible = False
End Sub

'Form overrides dispose to clean up the component
list.
Protected Overloads Overrides Sub Dispose(ByVal
disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the
Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents cmb As System.Windows.Forms.ComboBox
Friend WithEvents Button1 As
System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private
Sub InitializeComponent()
Me.cmb = New System.Windows.Forms.ComboBox()
Me.Button1 = New System.Windows.Forms.Button()
Me.SuspendLayout()
'
'cmb
'
Me.cmb.Location = New System.Drawing.Point(168,
112)
Me.cmb.Name = "cmb"
Me.cmb.Size = New System.Drawing.Size(121, 21)
Me.cmb.TabIndex = 0
Me.cmb.Text = "ComboBox1"
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point
(248, 72)
Me.Button1.Name = "Button1"
Me.Button1.TabIndex = 2
Me.Button1.Text = "Button1"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5,
13)
Me.ClientSize = New System.Drawing.Size(680, 463)
Me.Controls.AddRange(New
System.Windows.Forms.Control() {Me.Button1, Me.cmb})
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)

End Sub

#End Region

Private Sub Form1_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load

Dim xlApp As New Excel.Application()
xlApp = New Excel.Application()

End Sub

Private Sub Button1_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
Button1.Click

If m_blnFormVisible Then m_objForm.Hide() Else
m_objForm.Show()

m_blnFormVisible = Not m_blnFormVisible

End Sub
End Class

In case if this does not match the requirement, I will
appreciate if you can clarify on the exact scenario.
Regards,
Puneet Taneja
-----Original Message-----
Place the second form inside a panel control and add a button to your page.Set the panel's visibility to false at design time.

When the button is clicked change the panel's visibilty to true.
On the second button , set the panel's visibilty to false.
"adam" <ad********@go.com> wrote in message
news:04****************************@phx.gbl...
I have 2 forms.
Form1 has two buttons.
When i click button1 i would like form2 to open and show some objects on the form as visible.
If i click button2 i would like to set these objects
visible to false.

Can somebody tell me how i would do this using c#.

Maybe i can try using a boolean

thyanks
adam

.

Jul 21 '05 #3
Hi,

You can try using the following code.....

This is assuming that you have another form in the same
application with the name Form2.

Imports System.Data

Public Class Form1
Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

Private m_objForm As Form2
Private m_blnFormVisible As Boolean

Public Sub New()
MyBase.New()

'This call is required by the Windows Form
Designer.
InitializeComponent()

'Add any initialization after the
InitializeComponent() call
m_objForm = New Form2()
m_blnFormVisible = False
End Sub

'Form overrides dispose to clean up the component
list.
Protected Overloads Overrides Sub Dispose(ByVal
disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the
Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents cmb As System.Windows.Forms.ComboBox
Friend WithEvents Button1 As
System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private
Sub InitializeComponent()
Me.cmb = New System.Windows.Forms.ComboBox()
Me.Button1 = New System.Windows.Forms.Button()
Me.SuspendLayout()
'
'cmb
'
Me.cmb.Location = New System.Drawing.Point(168,
112)
Me.cmb.Name = "cmb"
Me.cmb.Size = New System.Drawing.Size(121, 21)
Me.cmb.TabIndex = 0
Me.cmb.Text = "ComboBox1"
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point
(248, 72)
Me.Button1.Name = "Button1"
Me.Button1.TabIndex = 2
Me.Button1.Text = "Button1"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5,
13)
Me.ClientSize = New System.Drawing.Size(680, 463)
Me.Controls.AddRange(New
System.Windows.Forms.Control() {Me.Button1, Me.cmb})
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)

End Sub

#End Region

Private Sub Form1_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load

Dim xlApp As New Excel.Application()
xlApp = New Excel.Application()

End Sub

Private Sub Button1_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
Button1.Click

If m_blnFormVisible Then m_objForm.Hide() Else
m_objForm.Show()

m_blnFormVisible = Not m_blnFormVisible

End Sub
End Class

In case if this does not match the requirement, I will
appreciate if you can clarify on the exact scenario.
Regards,
Puneet Taneja
-----Original Message-----
Place the second form inside a panel control and add a button to your page.Set the panel's visibility to false at design time.

When the button is clicked change the panel's visibilty to true.
On the second button , set the panel's visibilty to false.
"adam" <ad********@go.com> wrote in message
news:04****************************@phx.gbl...
I have 2 forms.
Form1 has two buttons.
When i click button1 i would like form2 to open and show some objects on the form as visible.
If i click button2 i would like to set these objects
visible to false.

Can somebody tell me how i would do this using c#.

Maybe i can try using a boolean

thyanks
adam

.

Jul 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
by: James Fortune | last post by:
I have a lot of respect for David Fenton and Allen Browne, but I don't understand why people who know how to write code to completely replace a front end do not write something that will automate...
3
by: Joshua Russell | last post by:
Hi, Both the methods below open up a windows form called MasterForm. However, one works better than the other. Method 1 opens the form correctly but I don't have any reference to the instance of...
7
by: Mike Bulava | last post by:
I have created a base form that I plan to use throughout my application let call the form form1. I have Built the project then add another form that inherits from form1, I add a few panel controls...
13
by: MD | last post by:
I have been converting a program from VB6 to VB.Net and enhancing it as well. All has been progressing OK although its been hard work. Now, all of a sudden, when I try to execute a ShowDialog()...
15
by: Joshua Kendall | last post by:
I have a script in which it keeps opening the same form instead of only one instance. I also need help with a form that has a password. Where do I put the actual password? can I use a database for...
3
by: Lloyd Sheen | last post by:
I have the following situation: Need a user resizable user control. After much trying with user control I came across the idea of hosting the controls in a form marked as not TopLevel = false. ...
8
by: Stephen Rice | last post by:
Hi, I have a periodic problem which I am having a real time trying to sort. Background: An MDI VB app with a DB on SQL 2000. I have wrapped all the DB access into an object which spawns a...
3
by: Geraldine Hobley | last post by:
Hello, In my project I am inheriting several forms. However when I inherit from a form and add additional subroutines and methods to my inherited form I get all sorts of problems. e.g. I sometimes...
6
by: dbuchanan | last post by:
I have a Windows Forms application that accesses SQL Server 2k from a small local network. The application has been used for weeks on other systmes but a new install on a new machine retruns...
21
by: Dan Tallent | last post by:
In my application I have a form (Customer) that I want to be able to open multiple copies at once. Within this form I have other forms that can be opened. Example: ZipCode. When the user enters...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.