How do I rearrange the columns in a DataGrid ?

The columns appear in the order in which their column styles were added to the tablestyle, being used by the grid. If you want to change this order, you need to create a new table style and add the column styles in the order you want things to appear. Here are some code snippets that suggest how to do this. [C#] public void MoveColumn(DataGrid _dataGrid, string _mappingName, int fromCol, int toCol) { if(fromCol == toCol) return; DataGridTableStyle oldTS = _dataGrid.TableStyles[_mappingName]; DataGridTableStyle newTS = new DataGridTableStyle(); newTS.MappingName = _mappingName; for(int i = 0; i < oldTS.GridColumnStyles.Count; ++i) { if(i != fromCol && fromCol < toCol) newTS.GridColumnStyles.Add(oldTS.GridColumnStyles[i]); if(i == toCol) newTS.GridColumnStyles.Add(oldTS.GridColumnStyles[fromCol]); if(i != fromCol && fromCol > toCol) newTS.GridColumnStyles.Add(oldTS.GridColumnStyles[i]); } _dataGrid.TableStyles.Remove(oldTS); _dataGrid.TableStyles.Add(newTS); } Sample usage private void button1_Click(object sender, System.EventArgs e) { MoveColumn( myDataGrid, ‘Customers’, 3, 1 ); }

How do I override the DataGridViewTextBox.Clone method ? In general, how do I implement ICloneable in a derived class ?

When the DataGridView needs to create a new cell in the column the method DataGridViewTextBoxCell.Clone is called in order to duplicate the ’DataGridViewColumn.CellTemplate’. It’s perfectly logical. You can override the Clone method, but you can’t call base.Clone() since it returns an object of the base class type and you can’t code a copy constructor because there is no copy constructor for DataGridViewTextBoxCell. With a base copy constructor you could code a Clone method like this : [C#] public override object Clone() { return new MyDataGridViewEditingTextBoxCell(this); } With your overridden copy constructor you could code a Clone method like this : public CustomDataGridViewTextBoxCell( CustomDataGridViewTextBoxCell cell) : base( cell ) { // Copy data of CustomDataGridViewTextBoxCell this.Flag = new Flag( cell.Flag ); this.Data = cell.Data.Clone() as Data; // … }

How can I use Event Trigger to control a StoryBoard after it is started ?

The following example uses controllable storyboard actions to interactively control a storyboard. [XAML] <Page xmlns=’http://schemas.microsoft.com/winfx/2006/xaml/presentation’ xmlns:x=’http://schemas.microsoft.com/winfx/2006/xaml’ WindowTitle=’Controlling a Storyboard’ > <StackPanel Margin=’20’ > <!– This rectangle is animated. –> <Rectangle Name=’myRectangle’ Width=’100′ Height=’20’ Margin=’12,0,0,5′ Fill=’#AA3333FF’ HorizontalAlignment=’Left’ /> <!– This StackPanel contains all the Buttons. –> <StackPanel Orientation=’Horizontal’ Margin=’0,30,0,0′> <Button Name=’BeginButton’>Begin</Button> <Button Name=’PauseButton’>Pause</Button> <Button Name=’ResumeButton’>Resume</Button> <Button Name=’SeekButton’>Seek</Button> <Button Name=’SkipToFillButton’>Skip To Fill</Button> <Button Name=’SetSpeedRatioButton’>Triple Speed</Button> <Button Name=’StopButton’>Stop</Button> <StackPanel.Triggers> <!– Begin the Storyboard –> <EventTrigger RoutedEvent=’Button.Click’ SourceName=’BeginButton’> <BeginStoryboard Name=’MyBeginStoryboard’> <Storyboard > <DoubleAnimation Storyboard.TargetName=’myRectangle’ Storyboard.TargetProperty=’Width’ Duration=’0:0:5′ From=’100′ To=’500′ /> </Storyboard> </BeginStoryboard> </EventTrigger> <!– Pause the Storyboard –> <EventTrigger RoutedEvent=’Button.Click’ SourceName=’PauseButton’> <PauseStoryboard BeginStoryboardName=’MyBeginStoryboard’ /> </EventTrigger> <!– Resume the Storyboard –> <EventTrigger RoutedEvent=’Button.Click’ SourceName=’ResumeButton’> <ResumeStoryboard BeginStoryboardName=’MyBeginStoryboard’ /> </EventTrigger> <!– Seek one second into the storyboard’s active period. –> <EventTrigger RoutedEvent=’Button.Click’ SourceName=’SeekButton’> <SeekStoryboard BeginStoryboardName=’MyBeginStoryboard’ Offset=’0:0:1′ Origin=’BeginTime’ /> </EventTrigger> <!– Skip to Fill –> <EventTrigger RoutedEvent=’Button.Click’ SourceName=’SkipToFillButton’> <SkipStoryboardToFill BeginStoryboardName=’MyBeginStoryboard’ /> </EventTrigger> <!– Stop the Storyboard –> <EventTrigger RoutedEvent=’Button.Click’ SourceName=’StopButton’> <StopStoryboard BeginStoryboardName=’MyBeginStoryboard’ /> </EventTrigger> <!– Triple the speed of the Storyboard –> <EventTrigger RoutedEvent=’Button.Click’ SourceName=’SetSpeedRatioButton’> <SetStoryboardSpeedRatio SpeedRatio=’3′ BeginStoryboardName=’MyBeginStoryboard’ /> </EventTrigger> </StackPanel.Triggers> </StackPanel> </StackPanel> </Page>