I hope someone can shed some light on an error I've been experiencing for
sometime now, but can no longer continue to ignore :-(
I've created a custom entity class which implements IEditableObject . I have
then created a custom collection for this custom entity which naturally
inherits CollectionBase and implements IBindingList.
When I bind my custom collection to a DataGridView and started editing, it
works correctly only up to the point where you try to navigate off a newly
created (but empty) grid row - the second time, at which point it errors with
an ArgumentOutOfRa nge exception.
The stack trace indicates the error occurs in the GetCellDisplayR ectangle
event and that the parameter name (of the invalid parameter) is rowIndex.
I'll try to explain a little better. If you add a row, by typing in some
values, the grid puts that row in "edit" mode and displays a new, empty row
below. If you use the arrow keys to move the cursor onto that new row, then
off again (down, then back up) everything is okay, if you repeat this process
(arrow back down to the new, empty row and back up again) the error occurs.
I suppose this must have something to do with what I am, or am not doing
with the custom collection but I've just built a really simplified version of
this, with just a couple of properties in the custom entity and no code other
than the basics in the collection (add, remove elements etc) and the error
still occurs.
Any help would be greatly appreciated.
Thanks in advance. 4 5884
"Stuart" <St****@discuss ions.microsoft. coma écrit dans le message de news: B2************* *************** **...icrosof t.com...
|I hope someone can shed some light on an error I've been experiencing for
| sometime now, but can no longer continue to ignore :-(
| I've created a custom entity class which implements IEditableObject . I
have
| then created a custom collection for this custom entity which naturally
| inherits CollectionBase and implements IBindingList.
You don't need to create your own custom collection classes, simply create
an instance of BindingList<You rClass>, passing an instance of
List<YourClasst o it if necessary. This then provides the required
functionality.
Joanna
--
Joanna Carter [TeamB]
Consultant Software Engineer
Thanks for your input Joanna.
Originally I was using Generics as you suggest, however I am extending the
custom colleciton in other ways and therefore need to understand / figure out
why this isn't working.
"Joanna Carter [TeamB]" wrote:
"Stuart" <St****@discuss ions.microsoft. coma écrit dans le message de news: B2************* *************** **...icrosof t.com...
|I hope someone can shed some light on an error I've been experiencing for
| sometime now, but can no longer continue to ignore :-(
| I've created a custom entity class which implements IEditableObject . I
have
| then created a custom collection for this custom entity which naturally
| inherits CollectionBase and implements IBindingList.
You don't need to create your own custom collection classes, simply create
an instance of BindingList<You rClass>, passing an instance of
List<YourClasst o it if necessary. This then provides the required
functionality.
Joanna
--
Joanna Carter [TeamB]
Consultant Software Engineer
"Stuart" <St****@discuss ions.microsoft. coma écrit dans le message de news: 18************* *************** **...icrosof t.com...
| Originally I was using Generics as you suggest, however I am extending the
| custom colleciton in other ways and therefore need to understand / figure
out
| why this isn't working.
In that case, does your list class implement ICancelAddNew ? This is
important and, if it is not there, sounds like it could be the cause of your
problem
Joanna
--
Joanna Carter [TeamB]
Consultant Software Engineer
That's it!
Thankyou so much Joanna.
I implemented the ICancelAddNew, and found I had to remove the item using
the itemIndex parameter (this.RemoveAt( itemIndex) ) in the CancelNew
funciton, and it works. (This itemIndex was increasing each time an item was
added, so the second time, the underlying list, seemed to have more items
than the DataGridView it was bound to...)
Thanks again Joanna.
I am off to investigate the BindingList<"ge nerics" solution you mentioned
as well. As I mentioned, I was using the standard List<generics approach
we had a couple of limitations with regards to business logic I wanted to
implement but the BindingList approach may well be more flexible in this
regard.
Thanks.
"Joanna Carter [TeamB]" wrote:
"Stuart" <St****@discuss ions.microsoft. coma écrit dans le message de news: 18************* *************** **...icrosof t.com...
| Originally I was using Generics as you suggest, however I am extending the
| custom colleciton in other ways and therefore need to understand / figure
out
| why this isn't working.
In that case, does your list class implement ICancelAddNew ? This is
important and, if it is not there, sounds like it could be the cause of your
problem
Joanna
--
Joanna Carter [TeamB]
Consultant Software Engineer This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: ME |
last post by:
I was running into a problem with the DataGridView while binding it to an
object Collection. I got it working and I thought others might like to know
how.
-------------- Problem -------------
The grid was bound to a simple object collection. The object contained
string and decimal properties, nothing to fancy. When an item was added to...
|
by: Dave A |
last post by:
Hi,
I am struggling with two way databinding in WinForms and the DataGridView.
I am binding to business object classes (rather than datatables). If I
have a collection of these business objects that is the datasource of a
DataBinding that is bound to a DataGridView (WinForms) then I was expecting
that any change to the data would be...
|
by: Steve |
last post by:
Hi-
OK, I've got a DataGridView, I've created a BindingSource from one of my
Business Entity object (based on generated classes from EntitySpaces) I've
left the default column setup so that all the columns are displayed.
My DataSource objects are composed like this:
class Customer : esCustomer // where esCustomer is the EntitySpaces...
|
by: Mitchell S. Honnert |
last post by:
Is there an equivalent of the DataGrid's DataGridTableStyle for the
DataGridView? If not, is there an easy way to duplicate the
DataGridTableStyle's functionality for the DataGridView?
Here's the background for my question...
Before I switched my application over to the Fx 2.0, I used a DataGrid to
display my data. I would store...
|
by: michael sorens |
last post by:
I have been trying to figure out how to use DataSets, BindingSources,
DataGridViews, and XML together, but it is a challenge. I understand how
to populate a DataGridView with XML basically as:
DataSet ds = new DataSet();
ds.ReadXml(@"\usr\tmp\sample.xml");
dataGridView.DataSource = ds;
dataGridView.DataMember = "targetElement";
What I...
| |
by: c_shah |
last post by:
I have the controls on my form display the values of the currently
selected row of the DataGridView. I am binding my DataGridView to a
collection
(Collection - which implements IBindingList Interface). I am binding
DataGridViewTextBoxColumn to the property of the objects in my
collection.
I have a combobox that should display a choice of...
|
by: Hexman |
last post by:
Hello All,
I'd like to find out the best way to add a cb column to a dgv and process efficiently. I see at least two ways of doing it.
-------------------------------
1) Add a cb to the dgv, iterate thru the dgv and update the bound fields if the cb has been checked. Then do the update and accept changes. How do I
access the cb and its...
|
by: rossmclean |
last post by:
Hi,
I am trying to add "x" number of DGV controls at run time. In my app
the user selects a dir with a number of mdbs in it. They then select
which dbs they want to run a common SQL against.
From here I want to load the results from each mdb into it's own DGV.
So far I have not been able to do this. I could dim a fix amount and
set a hard...
|
by: jehugaleahsa |
last post by:
Hello:
I am binding a DataGridView with a BindingList<T>, where T is a custom
business object that implements INotifyPropertyChanged.
When you bind a DataGridView to a DataTable, it has this cool little
feature - it will not call DataTable.Rows.Add until after you leave
the DataGridView row. This is cool because it lets your user edit the...
|
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...
|
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...
| |
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...
|
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...
|
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...
|
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...
|
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...
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |