We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

LoadCSSFromString() equivalent

What if I want to load a CSS from string? i.e., set the inline of the document using a string, instead of from a file or resource? I suppose I could create a memoryStream and use the load from stream... is that the best way? For example: If I want to modify the "strong" tag, so that it''s color: blue. The Css tag for this is very easy to accomplish, but how do I set the document''s CSS to use this, other than LoadCSS.

6 Replies

NR Nandakumar R Syncfusion Team May 25, 2006 09:45 AM UTC

Hi, The HTMLUIControl supports the definition of inline styles with the help of the style attribute and the class attribute. You can add a style attribute to the html element at run time and apply the style of the specific html element as string. Please refer the sample attached below that shows how an inline style is applied in the form of string to an html element at run time with the help of the style attribute. [C#] private void LoadCSSFromString(IHTMLElement element, string CSSstyle) {  if(element.Attributes.Contains("style") == false)   element.Attributes.Add("style");  element.Attributes["style"].Value = CSSstyle; } Thank you for your interest in Essential HTMLUI. Regards, Nanda LoadCSSFromString.zip


ER Eric Robishaw May 25, 2006 01:48 PM UTC

You misunderstood my question. Clarification: Example: I have the following html in the control:
hello
I want to establish what the element looks like by setting an in-line style sheet:

So the question is: How do I set the inline-css style sheet?


ER Eric Robishaw May 25, 2006 01:53 PM UTC

OK... that post didn''t work right, it stripped my html tags. If I have a strong tag in my html BODY: Hello And I want to define, using header css style setting: The question is: How do I setup the css header? So that any use of the STRONG tag in the document displays as Blue text?


NR Nandakumar R Syncfusion Team May 26, 2006 09:15 AM UTC

Hi Eric, Converting the inline style string to Stream and applying it to the document in the HTMLUI control using the LoadCSS method, is the best way I can suggest for this. This can be done as shown below, 1) Convert the CSS header string to Stream as shown below, [C#] using System.IO; using system.Text; Stream str = new MemoryStream(ASCIIEncoding.Default.GetBytes("strong {color: blue}")); 2) Then load the converted stream CSS in the HTMLUI control by, [C#] using Syncfusion.Windows.Forms.HTMLUI; htmluiControl.LoadCSS(str); I have attached here a sample that shows how the CSS header is set at run time with a string using the above steps. Please try this and let me know if this helps. Thank you for your interest in Essential HTMLUI. Regards, Nanda


NR Nandakumar R Syncfusion Team May 26, 2006 09:18 AM UTC

Hi Eric, Sorry for that the sample have not been displayed in the above post. Please try the sample attached here and let me know if this helps. Thank you for your interest in Syncfusion products. Regards, Nanda LoadCSSFromString.zip


ER Eric Robishaw May 26, 2006 09:11 PM UTC

perfect. Thankx

Loader.
Live Chat Icon For mobile
Up arrow icon