Nevron Forum

BestFit / ChooseColumns in NDataGridView control

https://www.nevron.com/Forum/Topic5777.aspx

By Tomas Vera - Tuesday, November 1, 2011

Hello,
I am using a NDataGridView control to display some data.

If I right-click a column header, a context-menu appears that allows me to ChooseColumns, apply BestFit and Order columns.

However, it seems I am not able to do this programatically.

Is there an event that I can fire which will allow the NDataGridView to perform the BestFit or the ChooseColumns functionality.

How can I trigger these events? Or is there another way to accomplish this?
By Nevron Support - Tuesday, November 1, 2011

Hello Tomas,

To perform best fit for specific column you should call
nDataGridView1.AutoResizeColumn(int columnIndex);

To perform best fit for all columns you should call
nDataGridView1.AutoResizeColumns();

Choose Columns dialog is implemented as an internal class and it cannot be displayed from other place than context menu.
However, this dialog is basically a form with nListView control which displays all columns of a NDataGridView as list items.
Each item's Tag property is set to the respective column, and when you check or uncheck an item the respective column becomes visible or not.

Hope this helps.


By Tomas Vera - Wednesday, November 2, 2011

Thanks!! This was exactly what I implemented. A NListBox with the column in the Tag property.