Databindings and default value

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?Tmljb2xhcw==?=

    Databindings and default value

    Yes another question about databindings.

    All my controls are have databindings and works fine for navigating, adding,
    deleting etc.
    What I want is when I create a New record have those fields pre-fill with
    some value stored in my user.setting so the user doesn't have to re-type
    evrything all the time.
    Should be so straight forward that I don't get it! The fields are not
    getting populated with those values.

    What is wrong with this code or method that I'm using?

    Private Sub TenantsBindingS ource_AddingNew (ByVal sender As Object, ByVal e
    As System.Componen tModel.AddingNe wEventArgs) Handles
    TenantsBindingS ource.AddingNew
    Me.txt_Address. Text = My.Settings.Add ress
    Me.txt_BasicPri ce.Value = My.Settings.Bas icPrice
    Me.txt_City.Tex t = My.Settings.Cit y
    Me.txt_Country. Text = My.Settings.Cou ntry
    Me.txt_PostalCo de.Value = My.Settings.Pos talCode
    Me.txt_Province .Text = My.Settings.Pro vince
    Me.txt_Suite.Te xt = My.Settings.Sui te
    End Sub


    Thanks for the help


  • Cor Ligthert[MVP]

    #2
    Re: Databindings and default value

    Nicolas,

    Why are you filling the controls and not to new source?
    I always use the source for this kind of problems.

    Cor

    "Nicolas" <Nicolas@discus sions.microsoft .comschreef in bericht
    news:ED494F90-7DEF-4A52-A230-B79FB1831CF0@mi crosoft.com...
    Yes another question about databindings.
    >
    All my controls are have databindings and works fine for navigating,
    adding,
    deleting etc.
    What I want is when I create a New record have those fields pre-fill with
    some value stored in my user.setting so the user doesn't have to re-type
    evrything all the time.
    Should be so straight forward that I don't get it! The fields are not
    getting populated with those values.
    >
    What is wrong with this code or method that I'm using?
    >
    Private Sub TenantsBindingS ource_AddingNew (ByVal sender As Object, ByVal e
    As System.Componen tModel.AddingNe wEventArgs) Handles
    TenantsBindingS ource.AddingNew
    Me.txt_Address. Text = My.Settings.Add ress
    Me.txt_BasicPri ce.Value = My.Settings.Bas icPrice
    Me.txt_City.Tex t = My.Settings.Cit y
    Me.txt_Country. Text = My.Settings.Cou ntry
    Me.txt_PostalCo de.Value = My.Settings.Pos talCode
    Me.txt_Province .Text = My.Settings.Pro vince
    Me.txt_Suite.Te xt = My.Settings.Sui te
    End Sub
    >
    >
    Thanks for the help
    >
    >

    Comment

    • =?Utf-8?B?Tmljb2xhcw==?=

      #3
      Re: Databindings and default value

      I want the user to see the field been filled properly and also I did not find
      where to change the new row source from the BindingsSource_ AddingNew function.

      Yes I would also prefer your idea. Do you have any hint for this using the
      datasource navigator feature which is the one I use.
      Thank you.

      "Cor Ligthert[MVP]" wrote:
      Nicolas,
      >
      Why are you filling the controls and not to new source?
      I always use the source for this kind of problems.
      >
      Cor
      >
      "Nicolas" <Nicolas@discus sions.microsoft .comschreef in bericht
      news:ED494F90-7DEF-4A52-A230-B79FB1831CF0@mi crosoft.com...
      Yes another question about databindings.

      All my controls are have databindings and works fine for navigating,
      adding,
      deleting etc.
      What I want is when I create a New record have those fields pre-fill with
      some value stored in my user.setting so the user doesn't have to re-type
      evrything all the time.
      Should be so straight forward that I don't get it! The fields are not
      getting populated with those values.

      What is wrong with this code or method that I'm using?

      Private Sub TenantsBindingS ource_AddingNew (ByVal sender As Object, ByVal e
      As System.Componen tModel.AddingNe wEventArgs) Handles
      TenantsBindingS ource.AddingNew
      Me.txt_Address. Text = My.Settings.Add ress
      Me.txt_BasicPri ce.Value = My.Settings.Bas icPrice
      Me.txt_City.Tex t = My.Settings.Cit y
      Me.txt_Country. Text = My.Settings.Cou ntry
      Me.txt_PostalCo de.Value = My.Settings.Pos talCode
      Me.txt_Province .Text = My.Settings.Pro vince
      Me.txt_Suite.Te xt = My.Settings.Sui te
      End Sub


      Thanks for the help
      >
      >
      >

      Comment

      • Cor Ligthert[MVP]

        #4
        Re: Databindings and default value

        Nicolas,

        What is your source?

        Cor

        "Nicolas" <Nicolas@discus sions.microsoft .comwrote in message
        news:6D1F0A41-E60F-4457-9924-312645DC77EA@mi crosoft.com...
        >I want the user to see the field been filled properly and also I did not
        >find
        where to change the new row source from the BindingsSource_ AddingNew
        function.
        >
        Yes I would also prefer your idea. Do you have any hint for this using the
        datasource navigator feature which is the one I use.
        Thank you.
        >
        "Cor Ligthert[MVP]" wrote:
        >
        >Nicolas,
        >>
        >Why are you filling the controls and not to new source?
        >I always use the source for this kind of problems.
        >>
        >Cor
        >>
        >"Nicolas" <Nicolas@discus sions.microsoft .comschreef in bericht
        >news:ED494F9 0-7DEF-4A52-A230-B79FB1831CF0@mi crosoft.com...
        Yes another question about databindings.
        >
        All my controls are have databindings and works fine for navigating,
        adding,
        deleting etc.
        What I want is when I create a New record have those fields pre-fill
        with
        some value stored in my user.setting so the user doesn't have to
        re-type
        evrything all the time.
        Should be so straight forward that I don't get it! The fields are not
        getting populated with those values.
        >
        What is wrong with this code or method that I'm using?
        >
        Private Sub TenantsBindingS ource_AddingNew (ByVal sender As Object,
        ByVal e
        As System.Componen tModel.AddingNe wEventArgs) Handles
        TenantsBindingS ource.AddingNew
        Me.txt_Address. Text = My.Settings.Add ress
        Me.txt_BasicPri ce.Value = My.Settings.Bas icPrice
        Me.txt_City.Tex t = My.Settings.Cit y
        Me.txt_Country. Text = My.Settings.Cou ntry
        Me.txt_PostalCo de.Value = My.Settings.Pos talCode
        Me.txt_Province .Text = My.Settings.Pro vince
        Me.txt_Suite.Te xt = My.Settings.Sui te
        End Sub
        >
        >
        Thanks for the help
        >
        >
        >>
        >>
        >>

        Comment

        • Cor Ligthert[MVP]

          #5
          Re: Databindings and default value

          I mean the Type of the DataSource


          "Nicolas" <Nicolas@discus sions.microsoft .comwrote in message
          news:6D1F0A41-E60F-4457-9924-312645DC77EA@mi crosoft.com...
          >I want the user to see the field been filled properly and also I did not
          >find
          where to change the new row source from the BindingsSource_ AddingNew
          function.
          >
          Yes I would also prefer your idea. Do you have any hint for this using the
          datasource navigator feature which is the one I use.
          Thank you.
          >
          "Cor Ligthert[MVP]" wrote:
          >
          >Nicolas,
          >>
          >Why are you filling the controls and not to new source?
          >I always use the source for this kind of problems.
          >>
          >Cor
          >>
          >"Nicolas" <Nicolas@discus sions.microsoft .comschreef in bericht
          >news:ED494F9 0-7DEF-4A52-A230-B79FB1831CF0@mi crosoft.com...
          Yes another question about databindings.
          >
          All my controls are have databindings and works fine for navigating,
          adding,
          deleting etc.
          What I want is when I create a New record have those fields pre-fill
          with
          some value stored in my user.setting so the user doesn't have to
          re-type
          evrything all the time.
          Should be so straight forward that I don't get it! The fields are not
          getting populated with those values.
          >
          What is wrong with this code or method that I'm using?
          >
          Private Sub TenantsBindingS ource_AddingNew (ByVal sender As Object,
          ByVal e
          As System.Componen tModel.AddingNe wEventArgs) Handles
          TenantsBindingS ource.AddingNew
          Me.txt_Address. Text = My.Settings.Add ress
          Me.txt_BasicPri ce.Value = My.Settings.Bas icPrice
          Me.txt_City.Tex t = My.Settings.Cit y
          Me.txt_Country. Text = My.Settings.Cou ntry
          Me.txt_PostalCo de.Value = My.Settings.Pos talCode
          Me.txt_Province .Text = My.Settings.Pro vince
          Me.txt_Suite.Te xt = My.Settings.Sui te
          End Sub
          >
          >
          Thanks for the help
          >
          >
          >>
          >>
          >>

          Comment

          • =?Utf-8?B?Tmljb2xhcw==?=

            #6
            Re: Databindings and default value

            I am using the dataset, dataAdapter, datasource, databindingSour ce object
            created automaticaly by dotnet connecting to my ms-access table
            I navigate over record via the datanavigator from dotnet.
            Basic stuff.
            When I create a new record I click on the add new button in the navigatorbar
            which is working fine and do what it is suppose to do. But at this point this
            is where I would like to have my field populated by default instead of having
            them blank

            Thanks


            Me.TenantsTable Adapter.Fill(Me .MTIDataSet.Ten ants)


            "Cor Ligthert[MVP]" wrote:
            Nicolas,
            >
            What is your source?
            >
            Cor
            >
            "Nicolas" <Nicolas@discus sions.microsoft .comwrote in message
            news:6D1F0A41-E60F-4457-9924-312645DC77EA@mi crosoft.com...
            I want the user to see the field been filled properly and also I did not
            find
            where to change the new row source from the BindingsSource_ AddingNew
            function.

            Yes I would also prefer your idea. Do you have any hint for this using the
            datasource navigator feature which is the one I use.
            Thank you.

            "Cor Ligthert[MVP]" wrote:
            Nicolas,
            >
            Why are you filling the controls and not to new source?
            I always use the source for this kind of problems.
            >
            Cor
            >
            "Nicolas" <Nicolas@discus sions.microsoft .comschreef in bericht
            news:ED494F90-7DEF-4A52-A230-B79FB1831CF0@mi crosoft.com...
            Yes another question about databindings.

            All my controls are have databindings and works fine for navigating,
            adding,
            deleting etc.
            What I want is when I create a New record have those fields pre-fill
            with
            some value stored in my user.setting so the user doesn't have to
            re-type
            evrything all the time.
            Should be so straight forward that I don't get it! The fields are not
            getting populated with those values.

            What is wrong with this code or method that I'm using?

            Private Sub TenantsBindingS ource_AddingNew (ByVal sender As Object,
            ByVal e
            As System.Componen tModel.AddingNe wEventArgs) Handles
            TenantsBindingS ource.AddingNew
            Me.txt_Address. Text = My.Settings.Add ress
            Me.txt_BasicPri ce.Value = My.Settings.Bas icPrice
            Me.txt_City.Tex t = My.Settings.Cit y
            Me.txt_Country. Text = My.Settings.Cou ntry
            Me.txt_PostalCo de.Value = My.Settings.Pos talCode
            Me.txt_Province .Text = My.Settings.Pro vince
            Me.txt_Suite.Te xt = My.Settings.Sui te
            End Sub


            Thanks for the help


            >
            >
            >
            >
            >

            Comment

            • Steve Gerrard

              #7
              Re: Databindings and default value

              Nicolas wrote:
              >
              This then create me all the object like dataset, datatable,
              dataadapter, datasourcebindi ngs, etc.
              >
              Then I do a databindings from the field property window with the
              "TenantsBinding Source - Name" bounded to Text
              I would not try to do default values with a bound textbox, or by catching an
              event of the binding source or navigator.

              The better place to set some default values is on the columns of the datatable
              itself.

              You sould be able to do something like
              TenantsTable.Co lumns("PostalCo de").DefaultVal ue = My.Settings.Pos talCode

              If you need to, you can also process the TenantsTable.Ta bleNewRow event to set
              initial values.


              Comment

              • =?Utf-8?B?Tmljb2xhcw==?=

                #8
                Re: Databindings and default value

                Excellent, this is what I was looking for.
                Was my first time using those control and did not know everything about those.

                Thank you

                "Steve Gerrard" wrote:
                Nicolas wrote:

                This then create me all the object like dataset, datatable,
                dataadapter, datasourcebindi ngs, etc.

                Then I do a databindings from the field property window with the
                "TenantsBinding Source - Name" bounded to Text
                >
                I would not try to do default values with a bound textbox, or by catching an
                event of the binding source or navigator.
                >
                The better place to set some default values is on the columns of the datatable
                itself.
                >
                You sould be able to do something like
                TenantsTable.Co lumns("PostalCo de").DefaultVal ue = My.Settings.Pos talCode
                >
                If you need to, you can also process the TenantsTable.Ta bleNewRow event to set
                initial values.
                >
                >
                >

                Comment

                Working...