473,401 Members | 2,146 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

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 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
Oct 21 '08 #1
7 1599
Nicolas,

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

Cor

"Nicolas" <Ni*****@discussions.microsoft.comschreef in bericht
news:ED**********************************@microsof t.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 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


Oct 22 '08 #2
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" <Ni*****@discussions.microsoft.comschreef in bericht
news:ED**********************************@microsof t.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 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


Oct 22 '08 #3
Nicolas,

What is your source?

Cor

"Nicolas" <Ni*****@discussions.microsoft.comwrote in message
news:6D**********************************@microsof t.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" <Ni*****@discussions.microsoft.comschreef in bericht
news:ED**********************************@microso ft.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 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



Oct 23 '08 #4
I mean the Type of the DataSource
"Nicolas" <Ni*****@discussions.microsoft.comwrote in message
news:6D**********************************@microsof t.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" <Ni*****@discussions.microsoft.comschreef in bericht
news:ED**********************************@microso ft.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 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



Oct 23 '08 #5
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)
"Cor Ligthert[MVP]" wrote:
Nicolas,

What is your source?

Cor

"Nicolas" <Ni*****@discussions.microsoft.comwrote in message
news:6D**********************************@microsof t.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" <Ni*****@discussions.microsoft.comschreef in bericht
news:ED**********************************@microsof t.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 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



Oct 23 '08 #6
Nicolas wrote:
>
This then create me all the object like dataset, datatable,
dataadapter, datasourcebindings, etc.

Then I do a databindings from the field property window with the
"TenantsBindingSource - 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.Columns("PostalCode").DefaultValue = My.Settings.PostalCode

If you need to, you can also process the TenantsTable.TableNewRow event to set
initial values.
Oct 24 '08 #7
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, datasourcebindings, etc.

Then I do a databindings from the field property window with the
"TenantsBindingSource - 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.Columns("PostalCode").DefaultValue = My.Settings.PostalCode

If you need to, you can also process the TenantsTable.TableNewRow event to set
initial values.
Oct 24 '08 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Richard | last post by:
Hi, I am trying to bind a datetime picker control to a column in a DataView and I get this exception: "Object reference not set to an instance of an object." Pseudo code looks like this: ...
0
by: Kyle Rowe | last post by:
Binding binding = new Binding("Text", x, null); textBox1.DataBindings.Add(binding); I wrote the aboe code when the form loads, but when I change the variable x, the textbox does not display the...
9
by: HAN(removethis)twister | last post by:
I've tried to create 11 textboxes as variables (not actually visible in the program, not in Windows Form Designer) and have set DataBindings to the text properties of the TextBoxes BUT according to...
6
by: Graham Blandford | last post by:
Hi all, I haven't received any replies to a previous question I posted regarding problems I was having with databound textboxes.. so I'll try a different angle... Can anyone point me in the...
2
by: Martin Horn | last post by:
Hi, I want to use databinding on a property for a class that I have created, but I can't make it work. Below is a contrived example to illustrate the problem. It seems that I can't databind...
2
by: C Glenn | last post by:
This is admitedly vague. But so is my understanding of the problem. I'm using this chunk of code: retControl.DataBindings.Add(ctrlBinding.PropertyName,DataSource,BindingField); This resolves...
4
by: Steve | last post by:
As you know there is a databindings property 'Enabled' for fields in the gridview. In the custom binding section I have used the expression: Eval("myfield"). 'myfield' is a boolean field I have...
1
by: Tom Scales | last post by:
OK, this one has me stumped. I am reading XML into a Dataset and then binding values to a label control. When displayed on the screen, the label control has the correct value in it. When I...
0
by: XenReborn | last post by:
Ok this should be simple. I made a form, added a combobox (for selecting items to edit, not for updating fields), several textboxes, a few checkboxes etc. On formshow it connects to my database,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.