Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / December 2004

Tip: Looking for answers? Try searching our database.

DataGrid: How to insert a row when bound to an ArrayList?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Steven Van Dyke - 09 Dec 2004 18:52 GMT
This should be simple, but I cannot figure it out. Given a datagrid, bound
to an arraylist, how should I go about inserting a new row above a selected
row?

Thanks,

Steve
serge gubenko - 09 Dec 2004 21:20 GMT
Hi,

IMO, since ArrayList isn't implementing IBindingList interface there is a
problem with adding and removing its items in DataGrid. You could create
your own list and implement IBindingList there in order to solve this
problem. Another quick workaround is to "rebind" arraylist each time you
adding a new row. Here's an example:

_____________________________
ArrayList mList = new ArrayList();

{...}

mList.Add(new MyItem(...));
dataGrid1.DataSource = null;
dataGrid1.DataSource = mList;
dataGrid1.Select(mList.Count-1);

where dataGrid1 is
System.Windows.Forms.DataGrid
_____________________________
hope this helps

Best regards, Serge Gubenko

> This should be simple, but I cannot figure it out. Given a datagrid, bound
> to an arraylist, how should I go about inserting a new row above a selected
[quoted text clipped - 3 lines]
>
> Steve

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.