返される StyleInfo の変更は、編集される値に効果がないことに注意してください。スタイルを変更するには、ApplyStyle(String,Boolean) メソッドを使用します。
Imports Infragistics.Shared Imports Infragistics.Win Imports Infragistics.Win.Misc Imports Infragistics.Win.FormattedLinkLabel Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles button1.Click Me.ultraFormattedTextEditor1.Value = "Test" Dim editInfo As FormattedTextEditInfo = Me.ultraFormattedTextEditor1.EditInfo ' Select some content. editInfo.SelectionStart = 0 editInfo.SelectionLength = 2 ' Apply some style to the selected content. editInfo.ApplyStyle("color: blue; background-color: yellow; font-size: +6pt;", False) ' Get the current style. This method returns style attributes that are common ' among all the selected contents. This method can be used to update the ' toolbar button states for example. Dim style As StyleInfo = editInfo.GetCurrentStyle() ' Print out the font size. It should be +6pt since that's what we set above. Debug.WriteLine("Font size: " & style.FontSize.ToString()) End Sub Private Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click Dim editInfo As FormattedTextEditInfo = Me.ultraFormattedTextEditor1.EditInfo ' Select something. ClearStyleAttributes and ClearAllStyleAttributes perform ' their operations on the selected content. editInfo.SelectAll() ' ClearStyleAttributes can be used to clear specific style attributes. Here ' we are clearing the font-size and background-color settings of the selected ' conents. editInfo.ClearStyleAttributes(New String() {"font-size", "background-color"}) ' You can also clear all the style attributes using the ClearAllStyleAttributes ' method. editInfo.ClearAllStyleAttributes() End Sub
using Infragistics.Shared; using Infragistics.Win; using Infragistics.Win.Misc; using Infragistics.Win.FormattedLinkLabel; using System.Diagnostics; private void button1_Click(object sender, System.EventArgs e) { this.ultraFormattedTextEditor1.Value = "Test"; FormattedTextEditInfo editInfo = this.ultraFormattedTextEditor1.EditInfo; // Select some content. editInfo.SelectionStart = 0; editInfo.SelectionLength = 2; // Apply some style to the selected content. editInfo.ApplyStyle( "color: blue; background-color: yellow; font-size: +6pt;", false ); // Get the current style. This method returns style attributes that are common // among all the selected contents. This method can be used to update the // toolbar button states for example. StyleInfo style = editInfo.GetCurrentStyle( ); // Print out the font size. It should be +6pt since that's what we set above. Debug.WriteLine( "Font size: " + style.FontSize.ToString( ) ); } private void button2_Click(object sender, System.EventArgs e) { FormattedTextEditInfo editInfo = this.ultraFormattedTextEditor1.EditInfo; // Select something. ClearStyleAttributes and ClearAllStyleAttributes perform // their operations on the selected content. editInfo.SelectAll( ); // ClearStyleAttributes can be used to clear specific style attributes. Here // we are clearing the font-size and background-color settings of the selected // conents. editInfo.ClearStyleAttributes( new string[] { "font-size", "background-color" } ); // You can also clear all the style attributes using the ClearAllStyleAttributes // method. editInfo.ClearAllStyleAttributes( ); }