Sort the rows of a datagridview but not the last two

Hi,
with this code, the last row isn't sorted:
Protected Overrides Sub OnSortCompare(ByVal e As System.Windows.Forms.DataGridViewSortCompareEventArgs)
MyBase.OnSortCompare(e)
If e.RowIndex1 = Me.RowCount - 1 Then e.Handled = True
If e.RowIndex2 = Me.RowCount - 1 Then e.Handled = True
End Sub
How can I expand this code to do not sort the second last row too?
This doesn't work:
Protected Overrides Sub OnSortCompare(ByVal e As System.Windows.Forms.DataGridViewSortCompareEventArgs)
MyBase.OnSortCompare(e)
If e.RowIndex1 = Me.RowCount - 1 Then e.Handled = True
If e.RowIndex2 = Me.RowCount - 1 Then e.Handled = True
If e.RowIndex1 = Me.RowCount - 2 Then e.Handled = True
If e.RowIndex2 = Me.RowCount - 2 Then e.Handled = True
End Sub

Hi DerStauner,
I have no idea about what do you mean “But I would like to fix the last two row”.
 My code seems sort correct all of the data in the datagridview. Would you like to share a sample about this?
Please pay attention that the sort method of ID is according to the string, so”10” will be before than “2”. If you want to compare the ID as integer, you need to change to your code to compare with integer instead of string.
Here is a sample (change the OnSortCompare method with following code):
Protected Overrides Sub OnSortCompare(ByVal e As System.Windows.Forms.DataGridViewSortCompareEventArgs)
MyBase.OnSortCompare(e)
'If e.RowIndex1 = Me.RowCount - 1 Then e.Handled = True
Dim a As Integer = CInt(e.CellValue1.ToString())
Dim b As Integer = CInt(e.CellValue2.ToString())
e.SortResult = a.CompareTo(b)
e.Handled = True
If e.RowIndex2 = Me.RowCount - 1 Then e.Handled = True
End Sub
Hope this helps.
Mark Liu-lxf [MSFT]
MSDN Community Support | Feedback to us

Similar Messages

  • Allt he links in the header of any websites are not working, I reinstalled fiorefix and it s the same. No problem in others browser. the tool bar is working but not the link sinside the web page located between the top 300px height

    all the links in the header of any websites are not working, the cursor is not changing into pointer and no way to click on any link located at the top of any website page. I reinstalled firefox and it s the same. No problem in others browser. the tool bar is working but not the links inside any web page located between the top 300px height.
    So I can t tlog into any website, i cant write an email as the compose button is located in the top of the page.. Please help, i have all my bookmarks into my firefox...

    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > Appearance/Themes).
    *Don't make any changes on the Safe mode start window.
    *https://support.mozilla.com/kb/Safe+Mode
    *https://support.mozilla.com/kb/Troubleshooting+extensions+and+themes

  • Why can't I save text I've entered into a PDF file?  When I hit "Save As", only the PDF document is saved, but not the text i typed into the document.  I'm using Windows 8.

    Why can't I save text I've entered into a PDF file?  When I hit "Save As", only the PDF document is saved, but not the text i typed into the document.  I'm using Windows 8.

    THANK YOU!
    Jan Whitfield
    The College Planning Center
    250 Palladio Parkway, Suite 1311
    Folsom, CA 95630
    (916) 985-0453
    www.TheCollegePlanningCenter.com

  • TS1389 Trying to play purchased TV series to my Apple TV, I am requested to authorise the computer.  This has already been done and I have tried the suggestions regarding authorisation.  I can play the programs on my computer, but not the Apple TV.

    Trying to play purchased TV series to my Apple TV, I am requested to authorise the computer.  This has already been done and I have tried the suggestions regarding authorisation.  I can play the programs on my computer, but not the Apple TV.
    Any ideas?

    in remote app click on the
    lower left corner on the text
    top of the context menu click devices
    choose the appletv rather then your shared lib in the list
    if you are trying to view a movie that is located on your ipad on your tv using the appletv then
    you should use airplay mirror not the remote app

  • How do you extend the frame from one side but not the whole thing?

    I am updating my blog and want to put a rectangle picture into the pre-set frame. I need to stretch it horizontally but the entire frame (i.e., both sides and top/bottom) stretched instead. How do you extend the frame from one side but not the whole thing?

    In Inspector, select the Graphic Inspector. Choose, from the Fill options, Image Fill. Select the image from the dropdown and click Open. Now go back to Inspector and click on Scale to Fit. Choose from the options in the window. There are a number of them which should address your problem:
    With the Blog template, you will probably need to insert a text box over the stock placement frame and work with that instead.
    Mark

  • I recently changed my PC and I transferred my iTunes music library to an external disc. Now, when I open iTunes I can only see the music I've downloaded, but not the rest of my music. Whatdo I need to do?

    I recently changed my PC and I transferred my iTunes music library to an external disc. Now, when I open iTunes I can only see the music I've downloaded, but not the rest of my music. What do I need to do?

    PDMex wrote:
    I recently changed my PC and I transferred my iTunes music library to an external disc.
    Did you transfer the entire /Music/iTunes/ folder?
    Or did you only transfer /Muisic/iTunes/iTunes media? folder?

  • I have made a webpage in HTML with several links to JPGs / GIFs. The text matter opens perfectly but not the images. Please help me

    I have made a web page in HTML with several links to JPGs / GIFs. While text matter opens up perfectly, but not the images. Please help me.
    == This happened ==
    Every time Firefox opened
    == User Agent ==
    Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; CTS Version; .NET CLR 1.1.4322; .NET CLR 2.0.50727)

    URL of that web page?

  • I can save the USA Paper as PDF, but not the Denver Post

    I can save the USA Paper as PDF file, but not the Denver Post.
    I currently have 4.0.1 firefox.

    When you select save PDF on your PlayBook and nothing happens. On ly up Adobe Reader on the PlayBook and see if they are in there

  • Is there a way to display the legend for a chart, but not the chart?

    Hi,
    I have a stacked column chart and a line chart on top of each other.   I can't use the legend for the stacked column chart because the data will change from month to month, and the 2 charts will not be aligned.  I copied the stacked column chart to another part of the canvas and want to display only the legend, but the chart is still displaying.  Is there a way to prevent the chart from displaying?    Thanks.

    hi Jim Wojewnik,
    we can show only the legend in a pie chart by dragging the edges to closer.do the following,
    select the pie chart,select the edge of the chart and make it small and u ll find the pie chart shrinking.make it lean such that the pie chart disappear.
    try this work around and let me know.
    regards,
    ravi.

  • Suddenly, my 1st gen can't access iTunes store.  It sits on "Accessing iTunes Store", with a spinning wheel for days.  I can access the store from my iMac, but not the Apple TV.  Everything is up to date.  What's the deal?

    I can't figure out why my 1st gen appletv cannot access the itunes store.  All newer movies are coming up to view and I can watch previews, but when I go to rent, it stays on the spinning wheel with the Accessing iTunes Store forever.  I've left it going for at least 4 or 5 days.  I can rent from my iMac, but all I have is the headphone, analog, 2-channel audio feed and not the true digital surround.  It sounded much better from the appletv.  HELP!

    Read a bunch of posts from 2008 and 2010.  The only step I found that I hadn't tried was the ol' plug pull.  After that, I got the first movie I tried renting.  ???  At least it works now.

  • My hp touch pad wont charge. the cord charges my phone but not the pad.

    the usp port got bent and I wrapped the cord around the device to provide contact but now nothing.  any remedy?  is there another way to charge it?

    If the port of the TouchPad won't allow for proper contact, your best option is to use a Touchstone charger.  Mine works great.  They are no longer available directly from HP, but check with third-party sellers like Amazon, eBay, or webOSNation.com
    smkranz
    I am a volunteer, and not an HP employee.
    Palm OS ∙ webOS ∙ Android

  • How do I backup the *contents* of a sparseimage (but not the actual image)?

    This is related to my iPhoto question:
    http://discussions.apple.com/thread.jspa?threadID=2590319
    I'd like to backup the contents of a sparseimage using TM. If I just point TM to the imagefile, I run in to the issue that each time I add/modify a file inside the image, then TM marks the whole image as changed and hence backs it all up. And since the image is large I run out of diskspace.
    Is there some way I can just back up the contents of the image? If my sparse image file is:
    /Users/shared/foo.sparseimage and it gets mounted as:
    /Volumes/foo
    is there someway I can point TM to /Volumes/foo and then exclude TM backing up /Users/shared/foo.sparseimage (I know how to do the latter).
    Thanks in advance.

    each time I add/modify a file inside the image, then TM marks the whole image as
    changed and hence backs it all up. And since the image is large I run out of
    diskspace.
    If you use a sparsebundle disk image instead of a sparseimage, that shouldn't happen.
    From this article
    [Discovering Sparse Bundle Disk Images|http://db.tidbits.com/article/9673]:
    A sparse bundle looks and acts just like a sparse image - it can grow in size, can optionally be compressed or encrypted, and so on. What's different is that it isn't actually a single file, as all previous disk image formats were. It's a bundle (also known as a package) - a folder that Mac OS X treats as a single file, which is also true of applications. (To verify this, you can Control-click or right-click a sparse bundle, choose Show Package Contents from the pop-up menu, and browse through its contents.) Inside that package is a folder full of bands - files that are each 8 MB in size, as many as are needed to hold the image's data.
    What's cool about this is that if you change something on a sparse bundle (adding or modifying a file, for instance), only the band(s) containing that data change, not the whole bundle. As a result, assuming your backup software treats the contents of bundles as individual files, you no longer have to back up a huge disk image just because a tiny file changed. Your backup software only has to copy the 8 MB band(s) containing any of that file's data (often only one). So I converted my encrypted sparse image to an encrypted sparse bundle, and now I can include it along with all my other files in my ordinary backups.
    ---------------------

  • ITunes is playing the audio on my movies but not the video.

    I have the latest version of iTunes along with Windows 8 and for some reason iTunes will not play the video part of my movies, just the audio. The screen appears as black when I try.

    Which encoding is used on that site?
    *Firefox > Web Developer > Character Encoding
    *View > Character Encoding
    For me the windows-1252 encoding is selected.

  • My email only shows the "to" and "from" info but not the content of the email. Please help. Thanks

    My email only shows the "to" and "from" info. There is no information at all in the body of my email messages. Please help. Thanks.

    Close the mail app and reboot the iPad.
    Tap the home button once. Then tap the home button twice and the recents tray will appear at the bottom of the screen. Tap and hold down on any app icon until it begins to wiggle. Tap the minus sign in the upper left corner of the mail icon. Tap the home button twice.
    Reboot the iPad by holding down on the sleep and home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider if it appears on the screen - let go of the buttons. Let the iPad start up.

  • The application runs from netbeans, but not the command-line

    Hi
    I have developed a GUI application using NetBeans. All source code files are compiling without problems and the program runs just fine when i press "run <app name>" in NetBeans. However, when i try to execute the jar file using the command "java -jar <name of jar>", then i get this error message (im standing in the same directory as the jar file which is the dist directory:
    $ java -jar /home/icebyte/NetBeansProjects/TripPlanner/dist/TripPlanner.jar
    Exception in thread "main" java.lang.NoClassDefFoundError: tripplanner/Main
    Caused by: java.lang.ClassNotFoundException: tripplanner.Main
    at java.net.URLClassLoader$1.run(URLClassLoader.java:221)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:209)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:324)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:269)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:337)
    Error: Could not find the main class.
    Error: A JNI error has occurred, please check your installation and try again
    Does someone know why i am getting this error ? I would be nice to find out. I have also tried to go into the src directory of the netbeans project and compile all files there which works fine, but when i try to run the program with "java <file that contains main method>" i get this error:
    Exception in thread "main" java.lang.NoClassDefFoundError: MainMenu (wrong name: tripplanner/MainMenu)
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:638)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:143)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:281)
    at java.net.URLClassLoader.access$000(URLClassLoader.java:74)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:216)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:209)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:324)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:269)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:337)
    Error: Could not find the main class.
    Error: A JNI error has occurred, please check your installation and try again
    I have JDK and JRE installed on the system (it came with netbeans). I have tried setting the JAVA_HOME variable, but there is no difference. Anyone? Thanks for all help.

    Hmm, i solved the problem now. I looked at this problem yesterday and couldnt find out why i was getting these stack traces, but now i know :)

Maybe you are looking for

  • Creating sales order using scheduling agreement eencountered this error

    Copying SHUM  LPN to OR is not defined Message no. V1473 Diagnosis The system does not have any settings for copying from SHUM  LPN to OR. System Response The system does not copy the item from the reference document. Procedure If you want to be able

  • IPad Mini/PDF Question

    Hi All, I was wondering if anyone has come across this problem.  I'm unable to open a specific PDF on my iPad, which I have no trouble opening on my iPhone.  Typically an option to "open in" Adobe pops up, bu on my iPad mini, I don't even have that o

  • No sample in BOE 3.0

    HI, I have installed BO XI 3.0 on windows. Everything is working fine. But I do not see sample universes and reports That we do  we XI R2 after installation. Do we need to add it manually or any other way. Any pointer would be very helpful --Kuldeep

  • WFA_FORECASTING error while attempting to Post WFAFC_A01 Idoc

    Hi All, I am attempting to load Historical Data into the WFM (WorkForce Management) system using Idocs. I am getting the error message WFA_FORECASTING071 "Sample set failed to insert any data" when processing using function module IDOC_INPUT_WFAFCHV.

  • How to Get Calendar Out of 6500 Slide?

    I'm trying to get my Calendar out of my 6500, so that I can get them into my Blackberry. There's no option in PC Suite (Calendar section) to export (unlike the Contacts section, which allows an export). I tried to Sync with Outlook but "What to Sync"