What events can I trap when a datagrid is sorted by clicking the column header?
Posted on 2004-11-29
I have a datagrid that uses a datagridstyle that allows for sorting (by clicking column header).
I made my own textcolumnstyle and added a method that would allow me to resize the dimensions of the cell based on the contents it holds.
My method works fine and the grid is able to display the cells wholly whenever I initialize the grid's contents (updating the data source).
However, once I click on the column header for sorting purposes, the cells in the grid are redrawn to their default (or minimum) width and height, thus cutting the display of cells with rather long texts (it supports multiline display).
I tried calling the method for resizing in the Paint method of the textcolumnstyle.
This initially solves my problem but the user is now unable to resize the dimensions of the cell, which is not good.
So I thought maybe I could call my resizing method in one of the events that happens during sorting.
What I found on the internet were mostly for ASP .NET and seems to be not applicable in my case.
Does anybody have a suggestion for me?
Should I disallow sorting from clicking column header and instead make a combo box that would let the user choose which column to sort? But in this case, how do I sort the grid then? I have a datatable as the data source of the grid.