We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

I am not getting a resized column to its previous state.

Hello ,
I am using syncfusion essential grid for wpf.
When i resize a column to its minimum size it will get hidden, and i am not getting that column back in to its previous state.
One morething i would like to know whether this grid control has a support to export data to Excel???


7 Replies

AD Administrator Syncfusion Team July 14, 2008 01:15 PM UTC

In our Windows Forms Grid, you double click the column header border to re-display a hidden column. Currently, this is not implemented in the WPF grid. But you could implement it catching an event.

//subscribe to the event
grid1.PreviewMouseDown += new MouseButtonEventHandler(grid1_PreviewMouseDown);

//the event handler
void grid1_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{
if (e.ClickCount == 2)
{
RowColumnIndex cell = grid1.PointToCellRowColumnIndex(e.GetPosition(grid1), true);
if (cell.RowIndex == 0 && cell.ColumnIndex > 0 && grid1.Model.ColumnWidths[cell.ColumnIndex - 1] == 0)
{
grid1.Model.ColumnWidths[cell.ColumnIndex-1] = grid1.ColumnWidths.DefaultLineSize;
grid1.InvalidateVisual(true);
}
e.Handled = true;
}
}


Our Windows Forms grids directly support Excel export through helper classes that use our XlsIO library to export the grids. Currently, this type of support is not in our WPF Grid library, but will be in some future release. I do not know of any announced dates for such support. Until then, you would have to use our XlsIO library directly to expect to Excel from our WPF Grid. This may be a simple task depending upon eaxctly what you want expected. If all you want is the values, then that would be straight-forwards. If you want some kind of WYSIWYG export, that would be a more extensive undertaking.




SU subindev July 15, 2008 03:48 AM UTC

Hello Clay,
Thanks a lot for your quick reply. I will try this snippet and let you know the result. I would like know about one more feature (Cell Sorting) that you provided in windows grid control. Is that feature available in WPF Grid Control also?

>In our Windows Forms Grid, you double click the column header border to re-display a hidden column. Currently, this is not implemented in the WPF grid. But you could implement it catching an event.

//subscribe to the event
grid1.PreviewMouseDown += new MouseButtonEventHandler(grid1_PreviewMouseDown);

//the event handler
void grid1_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{
if (e.ClickCount == 2)
{
RowColumnIndex cell = grid1.PointToCellRowColumnIndex(e.GetPosition(grid1), true);
if (cell.RowIndex == 0 && cell.ColumnIndex > 0 && grid1.Model.ColumnWidths[cell.ColumnIndex - 1] == 0)
{
grid1.Model.ColumnWidths[cell.ColumnIndex-1] = grid1.ColumnWidths.DefaultLineSize;
grid1.InvalidateVisual(true);
}
e.Handled = true;
}
}


Our Windows Forms grids directly support Excel export through helper classes that use our XlsIO library to export the grids. Currently, this type of support is not in our WPF Grid library, but will be in some future release. I do not know of any announced dates for such support. Until then, you would have to use our XlsIO library directly to expect to Excel from our WPF Grid. This may be a simple task depending upon eaxctly what you want expected. If all you want is the values, then that would be straight-forwards. If you want some kind of WYSIWYG export, that would be a more extensive undertaking.






AD Administrator Syncfusion Team July 15, 2008 06:58 AM UTC

Currently, there is no direct support for sorting in the WPF grid. But, if you virtually bind the grid to a datasource that supports sorting, (like a DataTable or sortable BindingList), then you can use tie that sorting support into the grid. Here is a link to a sample.
http://www.syncfusion.com/support/user/uploads/VirtualGridDataTableSort_4e45ef8d.zip



SU subindev July 15, 2008 07:06 AM UTC

This is excellent,
One more thing , i have tested ur previous code snippet (MouseButtonEventHandler). It is working very fine.But i cannot unhide the last row or last column if i resized...
any thanks a lot fop ur help and support.



AD Administrator Syncfusion Team July 15, 2008 07:23 AM UTC

You can tweak the code in the if statement to catch this last column case.

void grid_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{
if (e.ClickCount == 2)
{
RowColumnIndex cell = grid.PointToCellRowColumnIndex(e.GetPosition(grid), true);
if (cell.RowIndex == 0 && cell.ColumnIndex > 0)
{
if (grid.Model.ColumnWidths[cell.ColumnIndex - 1] == 0)
{
grid.Model.ColumnWidths[cell.ColumnIndex - 1] = grid.ColumnWidths.DefaultLineSize;
grid.InvalidateVisual(true);
}
else if (cell.ColumnIndex == grid.Model.ColumnCount - 2 && grid.Model.ColumnWidths[cell.ColumnIndex + 1] == 0)
{
grid.Model.ColumnWidths[cell.ColumnIndex + 1] = grid.ColumnWidths.DefaultLineSize;
grid.InvalidateVisual(true);
}
}
e.Handled = true;
}
}




SU subindev July 15, 2008 07:50 AM UTC

Thanks a lot Caly.:)



SU subindev July 15, 2008 08:00 AM UTC

Sorry:),
Thanks a lot Clay ..


Loader.
Live Chat Icon For mobile
Up arrow icon