c# - DataGridView unwanted calls to EndNew -


i using class called simplefilteredlist got site:

http://blogs.msdn.com/b/winformsue/archive/2007/12/06/filtering-code.aspx

it allows me apply basic sorting business objects when added datagridview through bindgingsource. has served purposes well, don't understand 1 aspect.

each time new row selected in datagridview prompts overridden endnew function in simplefilteredlist class called. particularly annoying when last row previous row selected because forces sorting algorithm executed.

all columns , datagridview have readonly set true, , allowusertoaddrows , allowusertodeleterows set false.

how can stop endnew function being called when new row selected in datagridview?

endnew function in simplefilteredlist class:

    public override void endnew(int itemindex)     {         // check see if item added end of list,         // , if so, re-sort list.         if (sortpropertyvalue != null && itemindex > 0 && itemindex == this.count - 1)             applysortcore(this.sortpropertyvalue, this.sortdirectionvalue);         base.endnew(itemindex);     } 

check index of item , ignore call if it's not specified.

note in scenarios, such windows forms complex data binding, collection may receive cancelnew or endnew calls items other newly added item. (each item typically row in data view.) ignore these calls; cancel or commit new item when item's index specified.

http://msdn.microsoft.com/en-us/library/system.componentmodel.icanceladdnew.aspx


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -