inputPanel DisableOnNoData

Posted by: kbj on 29 May 2018, 4:32 pm EST

    • Post Options:
    • Link

    Posted 29 May 2018, 4:32 pm EST

    It is unclear how DisableOnNoData works. I would think in the below example, the InputTextBox1 would be disabled.

    Public Class Form1

    Public lCustomers As New List(Of classCustomer)

    Private bsCustomers As New BindingSource

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load

    bsCustomers.DataSource = lCustomers

    InputTextBox1.DisableOnNoData = True

    InputTextBox1.DataBindings.Add(“Text”, bsCustomers, “customerName”)

    End Sub

    End Class

    Public Class classCustomer

    Public Property customerName As String

    End Class

  • Posted 30 May 2018, 12:20 am EST

    Hello,

    It is not enough to assign the DataSource property of InputTextBox. You also need to assign its DataField property to make the control data bound. The modified code snippet is:

    
    Public Class Form1
    Public lCustomers As New List(Of classCustomer)
        Private bsCustomers As New BindingSource
    
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            bsCustomers.DataSource = lCustomers
            InputTextBox1.DisableOnNoData = True
            'InputTextBox1.DataBindings.Add("Text", bsCustomers, "customerName")
            InputTextBox1.DataSource = bsCustomers
            InputTextBox1.DataField = "customerName"
        End Sub
    End Class
    Public Class classCustomer
        Public Property customerName As String
    End Class
    

    This will leave the InputTextBox disabled in case there is no data.

    Best Regards,

    Esha

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels