The C1RichTextBox for LightSwitch automatically switches to RTL when the culture is set. However, this blog deals with the implementation where only the C1RichTextBox layout needs to be changed instead of the entire application.
RTL-ing Layout of C1RichTextBox
Changing the layout of only C1RichTextBox for LightSwitch is very easy. We simply need to get the RichTextBox control in the ControlAvailable event and set the FlowDirection to RightToLeft. The C1RichTextBox would look as follows :
Here is the code :
IContentItemProxy proxy = this.FindControl("SourceText");
proxy.ControlAvailable += (s,e1)=>
if (e1.Control is C1RichTextBox)
rtb = e.Control as C1RichTextBox;
rtb.FlowDirection = System.Windows.FlowDirection.RightToLeft;
RTL-ing Collection C1RichTextBox
Things become different when C1RichTextBox is used inside the collection of say C1FlexGrid.
The trick here is to use the Ready property to ensure that the cells are created, then manipulate each RTB control separately.
First, add these using statements:
Then handle the ControlAvailable event like this:
partial void FlexibleEmployeesGrid_Created()
this.FindControl("C1FlexGrid").ControlAvailable += FlexibleEmployeesGrid_ControlAvailable;
void FlexibleEmployeesGrid_ControlAvailable(object sender, ControlAvailableEventArgs e)
LSFlexGrid flex = (LSFlexGrid)e.Control;
flex.Ready = delegate(LSFlexGrid grid)
foreach (var rtb in grid.Cells.Children
.Where(b => b.Child is C1RichTextBox)
.Select(b => ((C1RichTextBox)b.Child).Control as Control))
rtb.FlowDirection = FlowDirection.RightToLeft;
Resulting in RTL Cells:
Today’s C1RichTextBox enables a ton of great new scenarios, and makes building applications even easier.
If you don’t already have ComponentOne Studio for LightSwitch, you can sign-up for a free trial and start using all of the above features today.