Skip to main content Skip to footer

HowTo: Create a Bullet List in a Spread Cell

Recently one of our customers had a requirement of typing in a bullet list in the Spread cell. This is similar to one of the MS Excel functionality that allows you to type in a bullet list in the Excel worksheet cell. This blog discusses how this functionality can be achieved in Spread.

Step 1 : Create Custom Action to Enter New Line in Cell

Firstly, we would need to manipulate the default action performed on Spread when Alt+Enter key combination is pressed. This can be done by creating a new class inherited from the default Action class. This class would override the PerformAction method to enter the bullet symbol in the new line. Here is the code snippet for accomplishing the same:


public class myAction : FarPoint.Win.Spread.Action  
{  
  public override void PerformAction(object sender)  
  {  
     FarPoint.Win.Spread.SpreadView ss = (FarPoint.Win.Spread.SpreadView)sender;  
     FarPoint.Win.Spread.CellType.GeneralEditor editor = (FarPoint.Win.Spread.CellType.GeneralEditor)ss.EditingControl;  
     string text = editor.Text;  
     text += "\\r\\n \\u2022 ";  
     ss.Sheets[0].SetValue(ss.Sheets[0].ActiveRowIndex, ss.Sheets[0].ActiveColumnIndex, text);  
     ss.EditMode = true;  
     editor = (FarPoint.Win.Spread.CellType.GeneralEditor)ss.EditingControl;  
     editor.SelectionStart = editor.Text.Length;  
     editor.Text = text;  
  }  
}

Step 2 : Reset Default Action Map

Now reset the default action map defined for the Alt+Enter keys to call the above method that would automatically generate new line and bullets in the cell. We would need to use the SetInputMap method to accomplish the same. Here is the code snippet:


FarPoint.Win.Spread.InputMap ancestorOfFocusedMap = fpSpread1.GetInputMap(FarPoint.Win.Spread.InputMapMode.WhenAncestorOfFocused);  
FarPoint.Win.Spread.ActionMap am = fpSpread1.GetActionMap();  
am.Put("AltEnter", new myAction());  
ancestorOfFocusedMap.Put(new FarPoint.Win.Spread.Keystroke(Keys.Enter, Keys.None), FarPoint.Win.Spread.SpreadActions.MoveToNextRow );  
ancestorOfFocusedMap.Put(new FarPoint.Win.Spread.Keystroke(Keys.Enter, Keys.Alt), "AltEnter");  
fpSpread1.SetInputMap(FarPoint.Win.Spread.InputMapMode.WhenAncestorOfFocused, ancestorOfFocusedMap);  

OutputDemo1 Refer to the attached sample for complete implementation. Download C# sample Download VB sample

MESCIUS inc.

comments powered by Disqus