How to get a length of the shown text in the label - c#

I have a text with 1096 characters, and in the first page the label shown min 100 characters to 200 characters, click next button then remaining texts are shown in the same label(100 to 200 characters).
My question is how to get a shown text length when showing the first 100 or 200 texts. then only i can measure next characters to shown in the next page.
I did small sample code below.
string value = "wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww"
+ "wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww" + "wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww"
+ "wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww" + "wwwwwwwwwwwwwwww"
+ "wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww"
+ "wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww"
+ "wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww"
+ "wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww"
+ "wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww"
+ "wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww"
+ "w "
+ "wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww"
+ "wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww";
this.label1.Text = value;
Label Shows only 168 character in first page.
When I click next page I need to show remaining text..

Related

ITextSharper,position of string inside a paragraph

I need to add some space between values to make in centralized,i'm using blank space in strings ,but its not good,i need to put the strings in parameters in the same paragraph.
paragraph = new iTextSharp.text.Paragraph("Vlr Notas:" + VlrNotas + " Vlr Débitos:" + VlrDebito + " Data De Crédito:" + DtCredito, font2);
paragraph.Alignment = iTextSharp.text.Element.ALIGN_LEFT;
document.Add(paragraph);
I'm doing this,i need to put "VlrNotas" align left and in the center of the page the "VlrDébitos",is there a way to put in absoluto position?

Display new line of text document after pressing enter key

I'm currently pooping out, I am having trouble displaying lines from a text document. What I mean is whenever I press enter it displays a new line of the text document.
Thanks
This is I guess some code, this is referenced to a text document and received a definition, from here it receives it and gets it ready to display but I just need it to read from say result one line at a time every time I press enter
First line wont work this is the first line ->>>>
var result = GetLinesWithWord(i1, #"" + Path + "/dict2.txt");
// Display the results.
foreach (var line1 in result)
{
//word maxlength
const int MaxLength = 82;
var name1 = line1;
if (name1.Length > MaxLength)
name1 = name1.Substring(0, MaxLength);
Console.WriteLine(name1 + "\r");
string boc1 = name1;
string foc1 = i1;
System.IO.File.AppendAllText (#"" + Path + "/" + n + ".txt", foc1 + "\n" + boc1 + "\n");
If I understand you correctly (especcialy your comment to #MairajAhmad) you want to dump the text file line by line, waiting for the user to press a key after each line.
Look at the post here. I think, that is what you need. It's basically a call to Console.ReadKey(true). The mentioned post listen's for the escape key, but it should still illustrate what to do.

Print a list after being converted from string to a Label

I'm creating a standard calculator with a history feature. Previous solutions will show in a label box every time the user clicks the "=" button
After converting this string:
string histo = (operand1 + " " + operation + " " + " " + operand2 + " = " + result);
To a list by using this code:
List<string> hist = histo.Split().ToList()
What I want to do next is to print it to a label box to show history. How can I do that? Thank you.
Your question is not very clear and I do not think that label is a good choice to show the history. Combobox would be a better option, if you want to allow users to select items from history.
As far as your question on how to display it in a label is concerned you can use the following code. You can replace "," with Environment.NewLine.
lbl.Text = String.Join(",", hist);

Displaying form data in a message box

I am trying to display 3 values in a message box when the user clicks Submit as a means to verify correct input.
The 3 values come from comboBoxes in the form: age, height, weight.
In my current set up, the box will only say "age:" with the actual numerical value in the top border.
How can I get the 3 comboBox data items to appear inside a message box with appropriate titles?
Like this:
Age: 27
Height: 62
weight: 180
Data are stored in the variables age_Num.Text, height_Num.Text, and weight_Num.Text
MessageBox.Show("Age:", age_Num.Text); //just shows "Age:". Value is in titlebar of mb
In case of a ComboBox you can get the selected text through the ComboBox.SelectedText property.
To build a string from multiple values you can use String.Format().
string age = age_num.SelectedText;
string height = height_Num.SelectedText;
string weight = weight_Num.SelectedText
string text = String.Format(
"Age: {0}, Height: {1}, Weight: {2}", age, height, weight);
MessageBox.Show(text);
You must concatenate those values into a single string. Try this, using StringBuilder:
StringBuilder MessageText = new StringBuilder();
MessageText.AppendLine(string.Format("Age: {0}", age_Num.Text));
MessageText.AppendLine(string.Format("Height: {0}", height_Num.Text));
MessageText.AppendLine(string.Format("Weight: {0}", weight_Num.Text));
MessageBox.Show(MessageText.ToString());
You can use values of combo directly,
MessageBox.Show("Sometext 1:" + cbo1.SelectedValue.ToString() + " Sometext 2:" + cbo2.SelectedValue.ToString() + " Sometext 3:" + cbo3.SelectedValue.ToString());
or as you already have in variables.
MessageBox.Show("Age: " + age_num.Text + " Height: " + age_num.Text + " Sometext 3: " + weight_Num.Text);
If you don't like any of the above, simply create a dialog form set up as you want, with static function to show it modally.

adding space and new line in html editor asp.net ajax

I want to insert blank characters in a string move to next line and align right in Html editor ajax control and it should be hardcoded in my below code .
My code is
Editor1.Content = "No. J/" + DropDownList3.SelectedItem + "-" + TextBox1.Text + "-" + tyear + "/" + " " + "/" + year + DateTime.Now.Day+"/"+DateTime.Now.Month+"/"+DateTime.Now.Year;
What i want is
i want 5 blank spaces after
....+ tyear + "/" + "....
Move to next/new line after
....." + "/" + year +....
Apply Align left to this entire
content
To add blank spaces to the keyword. Normal blank spaces will be ignored as whitespace by the HTML parser.

Categories