473,911 Members | 5,861 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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<myc ustomobjectbut 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 5735
On Jul 22, 6:24*pm, Ste <sceru...@svilu pso.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<myc ustomobjectbut 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...@svilu pso.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<my customobjectbut 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
3529
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 and bind them to a datagrid using BindingList. I am in need of an epiphany here. Thank you. -Greg ******************BIND ARRAY OF CUSTOMER OBJECTS TO DATAGRID ************************ private Customer c; c =...
1
3050
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. The expected behavior would be for each of the first three to contain different sets numbers. public Form1() { InitializeComponent();
1
3114
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 list. The problem happens when: - I use such a BindingList as DataSource for a BindingSource. - Add this BindingSource as DataSource for a DataGridView. - And go to the NewRow and add a new row in the DataGridView.
3
2030
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 BindingList datasource, and then a ListChanged event should fire from the BindingList. However, the bindinglist's ListChanged event is not firing until a second key is pressed. I can press one key and nothing happens, but on the second key,...
5
7597
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 datagridview. I would like the ability to add to this collection or delete from this collection using the grid. I know I will need to use Bindinglist<T> for this but I don't seem to be able to cast from
1
1510
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. One of them is for instance SumItems, which returns me the sum of a given Property of all the Items in the List.
6
16850
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 data grid view - they both work. Are there aspects of databinding that the regular list will not support and vice-versa, is there any reason to choose a regular list over the bindinglist? -Jeff
1
1834
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. For example I might load the TermsNumber and TermsDescription from a database into the binding list and then use the combobox to feed into a customer setup form for default terms and for a order setup form for the individual order terms.
1
5115
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
10038
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
11057
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10541
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
8099
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7250
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5940
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6142
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4776
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4341
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.