2

Is there any event in spreadsheetgear for worksheet column width changing? I want to perform some operation when user clicks on column separator and drags it to change its width in worksheet.

What precisely I want to do is to show a small tooltip indicating width/height of column/row, when user changes column width by column header, or row height from row header. Microsoft Excel has this behaviour, we can see a tooltip appears near column header when we change width/height for column/row.

Thanks

1 Answers1

0

The WorkbookView class has an event called RangeChanged that triggers when a user changes the column width.

If you want to capture the new ColumnWidth after then change, the RangeChangedEventArgs parameter has that value.

public void workbookView1_RangeChanged(object sender, RangeChangedEventArgs e)
{
    ToolTip ttip = new ToolTip();
    ttip.Show(e.Range.ColumnWidth.ToString(), (SpreadsheetGear.Windows.Forms.WorkbookView)sender);
}

Be sure to add the following code to your designer.

  this.workbookView1.RangeChanged += new SpreadsheetGear.Windows.Forms.RangeChangedEventHandler(this.workbookView1_RangeChanged);
Daniel
  • 5,602
  • 4
  • 33
  • 36
  • Hi Daniel, Thanks for answer. But I do not see RangeChanged event firing when user changes column width from column header. What precisely I want to do is to show a small tooltip indicating width/height of column/row, when user changes column width by column header, or row height from row header. Microsoft Excel has this behaviour, we can see a tooltip appears near column header when we change width/height for column/row. – Shiv Ram Khatik Nov 29 '12 at 08:45
  • If you don't see it firing, make sure you wire the event up in the designer. I updated to answer with that code. – Daniel Nov 29 '12 at 14:49
  • I also added some code for displaying a tooltip with the column width. – Daniel Nov 29 '12 at 16:00
  • Hi Daniel, I actually meant that, this RangeChanged event only fired when we release mouse button after changing column header width. But not fired when we continuously drag mouse before releasing it. i.e. when mouse is pressed on column header and we move mouse (column width increase/decrease when mouse move), I want to show tooltip to display continuous changing width. Just like it happens in excel. – Shiv Ram Khatik Nov 30 '12 at 10:52
  • I see. You need something like a RangeChanging event not RangeChanged. I am not aware of an event like that in SSG. – Daniel Nov 30 '12 at 15:17
  • Is there any way to Restrict User from changing the column width or row height in spreadsheetgear – Ammar Nov 17 '14 at 09:43
  • Using the RangeChanged event like in the code above, you could set the column width or row height to whatever you want and inform the user in the tooltip their change is not allowed. – Daniel Nov 17 '14 at 15:53