Resize column as the cell is being edited

Is it possible to resize a GridControl column to fit while the user is editing a cell (rather than waiting until they complete their edit?

My problem is that if the cell is narrow and the user edits a cell and starts typing, what they type slowly scrolls to the left and disappears ie they can only see the last 'x' characters they typed (dependent on how many characters the width of the cell/column can accommodate).

I was hoping to call ResizeColumnsToFit when the CurrentCellChanged event fired (which appears to trigger with each keypress) but I think that function only 'sees' the original value and thus doesn't see any need to resize the cell/column.

Since I'm using virtual mode for my data (ie QueryCellInfo/CommitCellInfo) I had hoped I could work around this by updating the underlying cell value myself as the user typed (so ResizeColumnsToFit would see the updated cell value and resize accordingly) but I can't determine what the new value actually is.

Is there a way to resize as the user types or, alternatively, identify what edits the user has made as they enter them (and pick those up when CurrentCellChanged is fired)?

Thanks!

3 Replies

AR Arulpriya Ramalingam Syncfusion Team August 11, 2020 02:01 AM UTC

Hi Jeff, 
 
Thank you for your interest in Syncfusion products. 
 
We could understand the reported scenario that to resize the column width when the cell is editing at run time however, the GridControl does not have any built-in or extensibility support to achieve the reported requirement. Moreover, resizing the column during editing will lead to major performance issue and we suggest you to update the column width after the editing is completed using ResizeColumnWidths() method. 
 
Please get back to us, if you need any further assistance. 
 
Regards, 
Arulpriya 



JE Jeff August 11, 2020 03:20 AM UTC

Thanks Arulpriya.

The sample csv files I was using for testing didn't have headers. Now that they do the columns in the GridControl are naturally a lot wider by default (even if the non-header data is short) so the frequency of a user entering data wider than the cell is a lot less than I thought.

You are right that updating the width as the user typed would have an impact on performance.

Thanks for the feedback. :)


AR Arulpriya Ramalingam Syncfusion Team August 13, 2020 01:39 AM UTC

Hi Jeff, 
 
Thank you for the update. 
 
The for GridRows and GridColumns will not have any impact on ResizeColumnsToFit() unless the IncludeHeader option is specified. As we updated earlier, resizing columns on editing is not possible in GridControl for WPF. Please let us know, if you need any further assistance. 
 
Regards, 
Arulpriya 


Loader.
Up arrow icon