Databindings and default value

  • Thread starter Thread starter Nicolas
  • Start date Start date
N

Nicolas

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 TenantsBindingSource_AddingNew(ByVal sender As Object, ByVal e
As System.ComponentModel.AddingNewEventArgs) Handles
TenantsBindingSource.AddingNew
Me.txt_Address.Text = My.Settings.Address
Me.txt_BasicPrice.Value = My.Settings.BasicPrice
Me.txt_City.Text = My.Settings.City
Me.txt_Country.Text = My.Settings.Country
Me.txt_PostalCode.Value = My.Settings.PostalCode
Me.txt_Province.Text = My.Settings.Province
Me.txt_Suite.Text = My.Settings.Suite
End Sub


Thanks for the help
 
Nicolas,

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

Cor
 
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.
 
Nicolas,

What is your source?

Cor

Nicolas said:
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.
 
I mean the Type of the DataSource


Nicolas said:
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.
 
I am using the dataset, dataAdapter, datasource, databindingSource 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.TenantsTableAdapter.Fill(Me.MTIDataSet.Tenants)
 
I use from Visual Studio Menu Data/Add New Data Source
Database is ms-access
ConnectionString:Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=|DataDirectory|\MyDatabase.mdb

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

on Form_Load event it create this:
'TODO: This line of code loads data into the 'MTIDataSet.Tenants' table. You
can move, or remove it, as needed.
Me.TenantsTableAdapter.Fill(Me.MTIDataSet.Tenants)

Then I do a databindings from the field property window with the
"TenantsBindingSource - Name" bounded to Text

So obviously when I click AddNew from the TenantsBindingNavigator, it does
clear the field value and this is were I need to place back some default
value or text.

Is this answering your question in order to help me?
Again, thank you very much for your help.
 
Excellent, this is what I was looking for.
Was my first time using those control and did not know everything about those.

Thank you
 
Back
Top