473,406 Members | 2,633 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,406 software developers and data experts.

Override add on bindinglist

Ste
Good morning,
I have a bindinglist of my custom objects and need to check, before
adding items, if an item exists in list and then cancel inserting.

I have tried to create an object that inherits from
bindinglist<mycustomobjectbut I cannot override Add method.

This because this bindinglist is a datasource for a datagrid and need to
avoid to insert duplicated instances.

Thanks.
Stefano.
Jul 22 '08 #1
2 5688
On Jul 22, 6:24*pm, Ste <sceru...@svilupso.itwrote:
Good morning,
I have a bindinglist of my custom objects and need to check, before
adding items, if an item exists in list and then cancel inserting.

I have tried to create an object that inherits from
bindinglist<mycustomobjectbut I cannot override Add method.
You shouldn't override Add, you should override the protected
InsertItem method. It will be called for any operation that inserts a
new item into the list, be it Add or Insert.
Jul 22 '08 #2
Ste
Ok, but now I have tried to override EndNew method to find in the
innerlist if item was inserted (because only when I commit I have all
data to use for search) and then cancel it using CancelNew. The problem
is that ItemIndex parameter is alwais -1.

Thank you.
Stefano.

Pavel Minaev ha scritto:
On Jul 22, 6:24 pm, Ste <sceru...@svilupso.itwrote:
>Good morning,
I have a bindinglist of my custom objects and need to check, before
adding items, if an item exists in list and then cancel inserting.

I have tried to create an object that inherits from
bindinglist<mycustomobjectbut I cannot override Add method.

You shouldn't override Add, you should override the protected
InsertItem method. It will be called for any operation that inserts a
new item into the list, be it Add or Insert.
Jul 22 '08 #3

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

Similar topics

4
by: hazz | last post by:
The data access layer below returns, well, a mess as you can see on the last line of this posting. What is the best way to return customer objects via a datareader from the data layer into my view...
1
by: Dave Booker | last post by:
Is there a reason why the BindingList constructor doesn't create a new BindingList? Create a form with four ListBoxes and the following will result in them all containing the exact same thing. ...
1
by: Pieter | last post by:
Hi, I have a custom List that inherits from BindingList. It has some methods overloaded, like the Add/Insert/etc to add and remove some eventhandlers when adding or removing an item T of the...
3
by: Bryan | last post by:
I am calling BindingList.EndEdit during a 'TextChanged' sub for a texbox. In theory, the key should be pressed changing the value in the text box, the EndEdit call should append the changes to the...
5
by: Mike Surcouf | last post by:
Hi All I have a stored procedure wrapper that returns Collection<T>. The wrapper is generated by codesmith so I don't really want to start altering it. I need to use this collection in a...
1
by: Pieter | last post by:
Hi, I use a customized Generic List (VB.NET 2.0) inherited from BindingList(Of T). I made some methods in this BindingList, to allow me to do some standard functions on the BindingList-Items....
6
by: jwilson128 | last post by:
I am trying to decide whether to use a system.ComponentModel.BindingList(of T) or a Sytem.Collections.Generic.List(of T) for a custom collection. In testing a simple, read-only data binding to a...
1
by: Rick | last post by:
VS.net 2005 I'm using a bindinglist(of T) to bind to various controls on a WinForm. I use the name/value pairs in the "type" for the displayMember and ValueMember of say a ComboBox control. ...
1
by: =?Utf-8?B?RWl0YW4=?= | last post by:
Hello, I have a ComboBox named comboBoxSelChannel. I declared a structure named MySturct. public struct MyStruct { public int Index; public string Name;
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
0
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,...
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
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
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,...
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.