473,545 Members | 1,890 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

BindingSource IsNew

110 New Member
I am working on a group project where I do not have access to a BindingSource that is being passed through a function. The BindingSource's DataSource is set to a custom IBindingListVie w Collection.

When I try to set IsNew on the BindingSource having the custom IBindingListVie w, the BindingSource IsNew remaines false.

I have been able to do a test with my own IBindingListVie w being set on the BindingSource, and if I set IsNew before I set my DataSource, IsNew is True.

Here's a couple functions I have tried to set it to IsNew, but the first one removes the DataSource, but after setting it back, the DataSource is Nothing. The second one doesn't do anything, but is more in the lines of how I would like to set IsNew.

Expand|Select|Wrap|Line Numbers
  1. ' What I am trying to do
  2. Public Sub FooBindingSourceIsNew(Source As BindingSource, IsNew As Boolean)
  3. ....' This remains the same value as before, since the Source.DataSource has a value
  4. ....Source.IsNew = IsNew
  5. End Function
  6.  
Expand|Select|Wrap|Line Numbers
  1. ' Try 1
  2. Public Sub FooBindingSourceIsNew(Source As BindingSource, IsNew As Boolean)
  3. ....'This leaves me with Source.DataSource = Nothing
  4. ....Dim TmpDataMember As String = Source.DataMember
  5. ....Dim TmpDataSource As Object = Source.DataSource
  6.  
  7. ....Source.DataSource   = Nothing
  8. ....Source.DataMember = ""
  9.  
  10. ....Source.IsNew = IsNew
  11.  
  12. ....Source.DataMember = TmpDataMember
  13. ....Source.DataSource  = TmpDataSource
  14. End Function
  15.  
Expand|Select|Wrap|Line Numbers
  1. ' Try 2
  2. Public Sub FooBindingSourceIsNew(Source As BindingSource, IsNew As Boolean)
  3. ....'This does nothing different than leaving Source.IsNew as it's previous value
  4. ....Source.ResetBindings(False)
  5.  
  6. ....Source.IsNew = IsNew
  7.  
  8. ....Source.ResetBindings(True)
  9. End Function
  10.  
Well, Try 2 is an obvious failure, but I was frustrated, so I tried it : )

The real code is tied into a project I am working on for work, which is embedded in a derived DataGridView->TypedDataGridV iewT(Of T As Foo, U As Collection(Of T))--to be strongly typed.

So anyone using my grid will be able to pass in a DataSource, where I handle it and most of the time wrap a BindingSource around it. A few times a BindingSource is passed which is ok as well. But when it's a BindingSource which has IsNew false, and AllowUsersToAdd Rows is true, it causes grief for people using my grid.

I've probably talked too much, but it's been a while since I've been on here, and code crunch time will soon be over.

Hopefully Helpful,

TamusJRoyce
Mar 5 '09 #1
2 4646
TamusJRoyce
110 New Member
I'm assuming this form has became too hard to use for people to answer questions. I will be going elsewhere for helping people with and asking questions.

Thanks for everyones help that I've gotten in the past, and I may be back if this form ever recovers from its non-intuitive design...

TamusJRoyce
Mar 8 '09 #2
TamusJRoyce
110 New Member
Found out the reason why IsNew could not be set on the DataSource. My DataSource was a BindingSource with BindingSource.D ataMember = "Foo1" and also BindingSource.D ataSource = BindingSourceFo o2, where BindingSourceFo o2.DataMember = "" and BindingSourceFo o2.DataSource = "Foo2".

Complicated, but really what was happening is the "Foo2"->"Foo1" pointed to my desired collection. The DataSource was bound to a Form which was causing this behavior, even though BindingSource.D ataSource was explicitly being set to the desired collection.

So as a warning... BEWARE: BindingSources set graphically on a form handle DataSources strangely (well, how DataBinding does things behind the scenes). So BindingSource.D ataSource = collection won't result in BindingSource.D ataSource being a collection. So always explicitly define your own BindingSources.

.NET doing things behind the scenes against me again. :P

Hopefully Helpful,

TamusJRoyce
Mar 26 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
6659
by: mali_djuro | last post by:
Hi all, i got problem vwith method session.isNew in WAS 5. i check is new session or not, and if it is i fill it with some data, and if it is not i make session.invalidate and check again. but when i check while(!session.isNew){
3
3909
by: silesius | last post by:
Hi All, I have two pagetabs. One pagetab is used to display a parent record and the other is suppose to display 3 related child records from another table. I can display the parent records just fine by using the bindingSource and a tableAdapter to fill the dataset. I'm having a problem displaying the 3 related records on the other pagetab....
1
4522
by: TN | last post by:
I just don't get the BindingSource class when it is bound to a class. Consider this code snip: ..... Private bSource As New BindingSource() Private dgv As New DataGridView() Public Sub New() InitializeComponent()
0
4130
by: Geoff | last post by:
Hi folks Calling BindingSource.ResetCurrentItem() is changing the BindingSource.Position in a way I don't understand. If I'm understanding the docs correctly, ResetCurrentItem() should simply trigger an event which causes controls to refresh with the values of the current item with the index BindingSource.Position. This is not what I'm...
4
18700
by: shibeta | last post by:
Hello, I have problem with DataGridView and BindingSource. I have created DataSet and added TableData to it with manualy created columns (without DataAdapter - I'm not using MSSQL). On the Form I put DataGridView and BindingSource, and connected them (BindingSource of course is also connected with DataSet). Next on the separated thread I'm...
7
13437
by: Mike | last post by:
i have a small difficulties with BindingSource and dataGridView bind db has properly opened and bind doesn't works. Unfortunately I didn't find any good example how to connect MS Access with dataGridView and BindSource class. Maybe something like this: DataTable dtResult = new DataTable(); dtResult = GetData(); // this line returns a...
0
2113
nev
by: nev | last post by:
Have any of you encountered this? And how did you correct it? bs.addnew() automatically moves the position to the new record. But mine doesn't. I have 3 bindingsources in my program, all user-defined withevents. Their datasources come from MySQL tables. Now, in the positionchanged event, I've coded something like the one below......
2
4497
by: jehugaleahsa | last post by:
Hello: I'm working on improving some of our Windows Forms. I have created two user controls that I want to bind to the same BindingSource. I have an overview control that is used just to identify a customer. Then there is a details view that shows all their specifics. I wanted to keep navigation outside of my view. There is also a
5
4916
by: jehugaleahsa | last post by:
Hello: I am sure this question comes up a lot. I need to disable the controls on my Windows forms so that when the BindingSource is empty some the controls bound to it will be disabled. This will make it clear to the user that they have to create a new item first before they start working. This needs to be an easy process because there...
0
7478
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7410
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7923
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7773
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5984
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5343
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1025
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
722
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.