Author Topic: Main Form Properties  (Read 2208 times)

Ibrahim

  • Newbie
  • *
  • Posts: 35
    • View Profile
Main Form Properties
« on: November 28, 2014, 06:41:09 AM »
Hi there,

am new to this field, so i wanted to run the form without close button.
so how i could do to disable the close button on the form.
and instead of using the close button i need to use button and display message
yes/no and if yes to close the form.

thanks

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Main Form Properties
« Reply #1 on: November 28, 2014, 06:55:40 AM »
This will take a little bit of code to do.

- Set the FormBorderStyle of the Mainform to none
- Add a Button from the All Windows Forms group in the ToolBox
- Double click to the button to get back to the code
- Add this code:
Code: [Select]
    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        If MsgBox("Are you sure?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
            Close()
        End If
    End Sub

Ibrahim

  • Newbie
  • *
  • Posts: 35
    • View Profile
Re: Main Form Properties
« Reply #2 on: November 28, 2014, 07:27:26 AM »
Hi,

thanks alot,

if you can help me one more things it makes me happy,

there is programming right now which is running the company,
is there a way i can disable the close button, and i need only to disable the close button,
but the maximize and the minimize to be active.

thanks for your helping

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Main Form Properties
« Reply #3 on: November 28, 2014, 07:40:52 AM »
- in the Properties window of the form, click the lightening bolt to see the event list
- double click in the FormClosing event to get back to the code
- put in this code:
Code: [Select]
    Private Sub MainForm_FormClosing(sender As System.Object, e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
        If MsgBox("Are you sure?", MsgBoxStyle.YesNo) = MsgBoxResult.No Then
            e.Cancel = True
        End If
    End Sub

Ibrahim

  • Newbie
  • *
  • Posts: 35
    • View Profile
Re: Main Form Properties
« Reply #4 on: November 28, 2014, 08:05:27 AM »
Thanks alot

Ibrahim

  • Newbie
  • *
  • Posts: 35
    • View Profile
Re: Main Form Properties
« Reply #5 on: December 01, 2014, 03:11:16 AM »
Hi there,

is there some1 can help me  if i can run more forms in one project by using more plcs.
if so how i can do please.

thanks for advance.
« Last Edit: December 01, 2014, 07:13:06 AM by Ibrahim »

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Main Form Properties
« Reply #6 on: December 01, 2014, 07:37:36 AM »
is there some1 can help me  if i can run more forms in one project by using more plcs.
if so how i can do please.
You can add more forms to a project by right clicking the AdvancedHMI project in Solution Explorer and select Add->Windows Form

To communicate with multiple PLCs, add more drivers to a form, then set the ComComponent property of each control to tell it which PLC to retrieve the data from.

Ibrahim

  • Newbie
  • *
  • Posts: 35
    • View Profile
Re: Main Form Properties
« Reply #7 on: December 02, 2014, 04:09:24 AM »
Hi there,

this code below how i could add application title with excalmation or question marks on the message box plz
when the user clicks the close button and gets the message box i need to display question mark on the mgsbox and the application name

and this is the code am using without question mark or exclamation marks

  " Private Sub MainForm_FormClosing(sender As System.Object, e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
        If MsgBox("Are you sure?", MsgBoxStyle.YesNo) = MsgBoxResult.No Then
            e.Cancel = True
        End If
    End Sub"



Thanks
« Last Edit: December 02, 2014, 05:52:19 AM by Ibrahim »

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Main Form Properties
« Reply #8 on: December 02, 2014, 07:18:20 AM »
Try this:

  Private Sub MainForm_FormClosing(sender As System.Object, e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
        If MsgBox("Are you sure?", MsgBoxStyle.YesNo + MsgBoxStyle.Exclamation, "Title") = MsgBoxResult.No Then
            e.Cancel = True
        End If
    End Sub