Sort DataGridView on unbound column issue...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Frederik

    Sort DataGridView on unbound column issue...

    Hi group,

    I have a DataGridView that is mainly consisting of data bound columns.
    One column however is unbound. I'm not able to sort the grid on this
    column! Is that normal behaviour? If so, what are my options?

    Thanks (again) for your time,
    Frederik
  • RobinS

    #2
    Re: Sort DataGridView on unbound column issue...

    Yes, it is normal behavior. If the column is not databound, it doesn't know
    the underlying data source to handle the sorting.

    If you are using datasets or data tables, you could add a column to your
    dataset.

    Otherwise, you can try handling the sort stuff yourself. You could try
    capturing the column header click event, check to see what column it is, and
    sort it yourself.

    I just created a dgv bound to a BindingList<myO bj>, and found excellent
    examples for handling the sorting in Brian Noyes' Data Binding book.

    RobinS.
    GoldMail, Inc.
    ----------------------------------
    "Frederik" <frederik12@gma il.comwrote in message
    news:17a37c3d-7531-4398-aa0e-701d90a8c67b@e2 3g2000prf.googl egroups.com...
    Hi group,
    >
    I have a DataGridView that is mainly consisting of data bound columns.
    One column however is unbound. I'm not able to sort the grid on this
    column! Is that normal behaviour? If so, what are my options?
    >
    Thanks (again) for your time,
    Frederik

    Comment

    • Andrus

      #3
      Re: Sort DataGridView on unbound column issue...

      Otherwise, you can try handling the sort stuff yourself. You could try
      capturing the column header click event, check to see what column it is,
      and sort it yourself.
      How to capture mouse click in grid column header ?
      Grid OnMouseClick not not have such flag.

      Andrus.


      Comment

      • RobinS

        #4
        Re: Sort DataGridView on unbound column issue...

        Capture the ColumnHeaderMou seClick event.

        Or capture the CellClick event, and check the rowindex in the
        DataGridViewCel lEventArgs. If it's -1, they clicked on the header.

        RobinS.
        GoldMail, Inc.
        -------------------------------
        "Andrus" <kobruleht2@hot .eewrote in message
        news:OA9s33jcIH A.1168@TK2MSFTN GP02.phx.gbl...
        >Otherwise, you can try handling the sort stuff yourself. You could try
        >capturing the column header click event, check to see what column it is,
        >and sort it yourself.
        >
        How to capture mouse click in grid column header ?
        Grid OnMouseClick not not have such flag.
        >
        Andrus.
        >
        >

        Comment

        Working...