Word wrap a string in multiple lines

static void Main(string[] args) { List<string> lines = WrapText(“Add some text”, 300, “Calibri”, 11); foreach (var item in lines) { Console.WriteLine(item); } Console.ReadLine(); } static List<string> WrapText(string text, double pixels, string fontFamily, float emSize) { string[] originalLines = text.Split(new string[] { ” ” }, StringSplitOptions.None); List<string> wrappedLines = new List<string>(); StringBuilder actualLine = new StringBuilder(); … Read more

How to remove word wrap from textarea?

textarea { white-space: pre; overflow-wrap: normal; overflow-x: scroll; } white-space: nowrap also works if you don’t care about whitespace, but of course you don’t want that if you’re working with code (or indented paragraphs or any content where there might deliberately be multiple spaces) … so i prefer pre. overflow-wrap: normal (was word-wrap in older … Read more

finding “line-breaks” in textarea that is word-wrapping ARABIC text

Well, instead of finding the line breaks (which is virtually impossible) you can force them into the textarea, using this function: function ApplyLineBreaks(strTextAreaId) { var oTextarea = document.getElementById(strTextAreaId); if (oTextarea.wrap) { oTextarea.setAttribute(“wrap”, “off”); } else { oTextarea.setAttribute(“wrap”, “off”); var newArea = oTextarea.cloneNode(true); newArea.value = oTextarea.value; oTextarea.parentNode.replaceChild(newArea, oTextarea); oTextarea = newArea; } var strRawValue = oTextarea.value; … Read more