12 Replies - 1515 Views - Last Post: 03 August 2012 - 09:56 AM Rate Topic: -----

#1 AnalyticLunatic  Icon User is offline

  • D.I.C Lover

Reputation: 223
  • View blog
  • Posts: 1,035
  • Joined: 25-June 12

CheckBox Value always 'False'

Posted 02 August 2012 - 07:20 AM

Hello everyone, I am hoping someone can explain what is going on.

I have two forms, frmTransactionsAdd and frmReportView. When I select some items from the DataGridView in frmTransactionsAdd and click a button "Print Licenses", frmReportView opens and displays a report with data from the selected rows filled in.

This report needs to Duplex Print, and since I do not know what printer the final user shall be using, nor if the printer shall be dedicated to this one feature, I have encoded a checkbox on frmTransactionsAdd '[] Show Print Instructions' and under the function that fires when frmReportView opens I have:

MessageBox.Show(CStr(frmTransactionsAdd.chkLicPrintInstructions.Checked))
                    If frmTransactionsAdd.chkLicPrintInstructions.Checked = True Then
                        frmPrintInstructions.Show()
                    End If


The issue I am having is that despite the '[] Show Print Instructions' checkbox being checked or not, the value is always registering as False, thus my small form with instructions on duplex printing the report is never shown to the user.

I am trying to do things this way because a user who does this every day will not want to see the Instructions Form every time they go to print a license, but also if it is someone new, they may not know what to do.

When the user wants the Instructions, I need it to be the top-most visible form, without locking out everything else as it would with a .ShowDialog(), because the user still has other options they can do to the report before selecting print.

Can anyone tell me why the value is always registering as false? or perhaps even a better way to do this?

Is This A Good Question/Topic? 0
  • +

Replies To: CheckBox Value always 'False'

#2 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1067
  • View blog
  • Posts: 4,174
  • Joined: 02-July 08

Re: CheckBox Value always 'False'

Posted 02 August 2012 - 07:40 AM

It might be due to you using the class form control - which you set to unchecked in the designer. so your not really making a New form and using that instance - which would reflect the change.

'form instance - the runtime version
Dim frm As New frmTransactionsAdd
MessageBox.Show(frm.chkLicPrintInstructions.Checked.ToString)

Was This Post Helpful? 0
  • +
  • -

#3 AnalyticLunatic  Icon User is offline

  • D.I.C Lover

Reputation: 223
  • View blog
  • Posts: 1,035
  • Joined: 25-June 12

Re: CheckBox Value always 'False'

Posted 02 August 2012 - 07:57 AM

View Post_HAWK_, on 02 August 2012 - 07:40 AM, said:

It might be due to you using the class form control - which you set to unchecked in the designer. so your not really making a New form and using that instance - which would reflect the change.

'form instance - the runtime version
Dim frm As New frmTransactionsAdd
MessageBox.Show(frm.chkLicPrintInstructions.Checked.ToString)


_HAWK_, thanks for the reply. I'm not quite sure I understand what you mean?
Was This Post Helpful? 0
  • +
  • -

#4 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1067
  • View blog
  • Posts: 4,174
  • Joined: 02-July 08

Re: CheckBox Value always 'False'

Posted 02 August 2012 - 08:07 AM

Did you make a new instance of your class? Or just call the class objects? If I have a class named form1 I can write it in code, but it won't have any values or have been initialized, but still legal to write in code.
Was This Post Helpful? 0
  • +
  • -

#5 AnalyticLunatic  Icon User is offline

  • D.I.C Lover

Reputation: 223
  • View blog
  • Posts: 1,035
  • Joined: 25-June 12

Re: CheckBox Value always 'False'

Posted 02 August 2012 - 08:10 AM

View Post_HAWK_, on 02 August 2012 - 08:07 AM, said:

Did you make a new instance of your class? Or just call the class objects? If I have a class named form1 I can write it in code, but it won't have any values or have been initialized, but still legal to write in code.


frmTransactionsAdd remains open and when "Print Licenses" is clicked, frmReportView opens. In the procedure that loads the report for frmReportView, I am simply trying to check the value of the whether chkLicPrintInstructions on frmTransactionsAdd is True or False to show the Print Instructions Form.
Was This Post Helpful? 0
  • +
  • -

#6 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1067
  • View blog
  • Posts: 4,174
  • Joined: 02-July 08

Re: CheckBox Value always 'False'

Posted 02 August 2012 - 09:18 AM

How did you create the frmTransactionsAdd form?

frmTransactionsAdd.Show() 'or
Dim frm As New frmTransactionsAdd
frm.Show()

Was This Post Helpful? 0
  • +
  • -

#7 AnalyticLunatic  Icon User is offline

  • D.I.C Lover

Reputation: 223
  • View blog
  • Posts: 1,035
  • Joined: 25-June 12

Re: CheckBox Value always 'False'

Posted 02 August 2012 - 09:51 AM

View Post_HAWK_, on 02 August 2012 - 09:18 AM, said:

How did you create the frmTransactionsAdd form?

frmTransactionsAdd.Show() 'or
Dim frm As New frmTransactionsAdd
frm.Show()



Dim frm As New frmTransactionsAdd
frm.StartMode = frmTransactionsAdd.EnumStartMode.Search
Call LoadForm(frm)

Was This Post Helpful? 0
  • +
  • -

#8 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2271
  • View blog
  • Posts: 9,499
  • Joined: 29-May 08

Re: CheckBox Value always 'False'

Posted 02 August 2012 - 10:00 AM

In vb.net there's no need for the Call, it there for legacy code.
Was This Post Helpful? 0
  • +
  • -

#9 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1067
  • View blog
  • Posts: 4,174
  • Joined: 02-July 08

Re: CheckBox Value always 'False'

Posted 02 August 2012 - 10:52 AM

Ok, since you are making an instance of that form you can not call it by it's default name - they are not the same object. If that form calls the preview form I would use an Event on the preview form that the transaction form subscribes to and pass the data by the RaiseEvent route. Are you familiar with events?

Could you show us the LoadForm method?

This post has been edited by _HAWK_: 02 August 2012 - 10:51 AM

Was This Post Helpful? 0
  • +
  • -

#10 AnalyticLunatic  Icon User is offline

  • D.I.C Lover

Reputation: 223
  • View blog
  • Posts: 1,035
  • Joined: 25-June 12

Re: CheckBox Value always 'False'

Posted 02 August 2012 - 11:22 AM

View PostAdamSpeight2008, on 02 August 2012 - 10:00 AM, said:

In vb.net there's no need for the Call, it there for legacy code.

Thanks, I am simply updating, not the creator. That's how all of it is set up.

View Post_HAWK_, on 02 August 2012 - 10:52 AM, said:

Ok, since you are making an instance of that form you can not call it by it's default name - they are not the same object. If that form calls the preview form I would use an Event on the preview form that the transaction form subscribes to and pass the data by the RaiseEvent route. Are you familiar with events?

Could you show us the LoadForm method?


Ok, that makes a little sense as to why the original object is then always being flagged as Checked = False. I am somewhat familiar with events. I'm not quite understanding what you mean by 'subscribing' to though?

LoadForm Method:

    Private _loadForm As frmLoading
    Public Property LoadForm() As frmLoading
        Get
            Return _loadForm
        End Get
        Set(ByVal value As frmLoading)
            _loadForm = value
        End Set
    End Property

Was This Post Helpful? 0
  • +
  • -

#11 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1067
  • View blog
  • Posts: 4,174
  • Joined: 02-July 08

Re: CheckBox Value always 'False'

Posted 02 August 2012 - 11:51 AM

LoadForm is a property??? That makes no sense. Where does the form get initialized?

Public Class frmPrintInstructions
  Public Event SomeEvent(data As String)

  'somewhere on this form you call 
  RaiseEvent(data)
  ' and the form that subscribed to this event will receive this data  
'rest of your code...




'where ever you make this form
Dim frm As New frmPrintInstructions
'subscribe to the event
Addhandler frm.SomeEvent, AddressOf SomeEvent
frm.Show()


Private Sub SomeEvent(data As String)
  'data would be the data passed by the event
  'change it to whatever data type you need
  'the signature must match '(data As String)'
End Sub

Was This Post Helpful? 1
  • +
  • -

#12 AnalyticLunatic  Icon User is offline

  • D.I.C Lover

Reputation: 223
  • View blog
  • Posts: 1,035
  • Joined: 25-June 12

Re: CheckBox Value always 'False'

Posted 02 August 2012 - 12:06 PM

View Post_HAWK_, on 02 August 2012 - 11:51 AM, said:

LoadForm is a property??? That makes no sense. Where does the form get initialized?

Public Class frmPrintInstructions
  Public Event SomeEvent(data As String)

  'somewhere on this form you call 
  RaiseEvent(data)
  ' and the form that subscribed to this event will receive this data  
'rest of your code...

'where ever you make this form
Dim frm As New frmPrintInstructions
'subscribe to the event
Addhandler frm.SomeEvent, AddressOf SomeEvent
frm.Show()

Private Sub SomeEvent(data As String)
  'data would be the data passed by the event
  'change it to whatever data type you need
  'the signature must match '(data As String)'
End Sub



Here is everything from frmPrintInstructions:

Public Class frmPrintInstructions
    Private Sub frmPrintInstructions_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.TopMost = True
    End Sub

    Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
        Me.Close()
    End Sub
End Class

Was This Post Helpful? 0
  • +
  • -

#13 AnalyticLunatic  Icon User is offline

  • D.I.C Lover

Reputation: 223
  • View blog
  • Posts: 1,035
  • Joined: 25-June 12

Re: CheckBox Value always 'False'

Posted 03 August 2012 - 09:56 AM

_HAWK_, thanks for the help. I know this wasn't the clearest issue to explain and I'm not the most experienced to work with. I found out a way to reorder some show/showdialog events to where now I have what I needed without passing anything.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1