How do I implement string alignment in Winform?

Updated on technology 2024-04-06
12 answers
  1. Anonymous users2024-02-07

    Alignment is how paragraph content is arranged horizontally between the left and right boundaries of the document. There are a total of 5 alignment styles in Word: Left Alignment, Right Alignment, Center Alignment, Ends Alignment, and Scattered Alignment.

    Left alignment is to align the left edge of a text paragraph;

    Alignment is the alignment of the edges of both the left and right ends of a text paragraph;

    Similarities and differences: Both alignments are aligned to the left, and generally speaking, if the last line at the end of the paragraph has too few words, then the "alignment" of the last line has the same effect as the "left-aligned"; And because our reading habits are basically from left to right, and the end of the line in Chinese articles is not different, and we can't see the difference if we don't pay attention, people will feel that "left alignment" has the same effect as "both ends aligned".

    Actually, there is a difference between the two, the right side of the paragraph that is "aligned at both ends" is also aligned, while the right side of the paragraph that is "aligned left" is generally not aligned. Try it: You type a long piece of English text into Word, use two different alignments, and if you look closely, you'll see the difference.

    Because in general, we have such a writing rule:

    Most punctuation marks cannot be placed at the beginning of a line, such as a period". "Question mark"? etc.;

    A string of characters (an English word, a string of numbers) cannot be separated or placed on two different lines;

    Therefore, under such writing rules, we often encounter the situation that the number of words (characters) in each line of the article is not equal, at this time, the use of the "left alignment" method, there will be an untidy situation at the end of each line, and the use of the "two ends alignment" method, the excess line will be compressed, the reduced line will be stretched, so that the right end of each line of the whole paragraph is also aligned (except for the last line), such an article looks more beautiful.

    In ended-end alignment, text appears to be unaligned because the last line of each paragraph is usually shorter than the others. To align the last line in a paragraph with ended-end formatting, place the insertion point at the end of the last line and press Shift+Enter. Note that if the aligned line is short, a large white space will be inserted between the words, which will make the line look unsightly.

  2. Anonymous users2024-02-06

    Don't use textbox, just datagridview.

  3. Anonymous users2024-02-05

    Like this, it's better to use ListView to implement it relatively simply.

  4. Anonymous users2024-02-04

    If the ends are aligned, the short line will be very thin. I really don't know if there's an easy way to do this.

  5. Anonymous users2024-02-03

    A simple textbox is not easy to get, if it is to imitate QQ, you can see that it is not simply a device, but similar to a dynamic textbox in a panel, to give you an example.

    Create a new winform, drag a panel, generate a load event, and paste **private void testtextalign load(object sender, eventargs e).

    int lasttop = 0;topprivate void addmsg(string msg, bool left) of the last textbox

  6. Anonymous users2024-02-02

    The contents of the textbox are simple strings, so you can't set up such a complex format.

    It is recommended that you add some spaces in front of the string where you need to be right-aligned, so that you can also achieve the effect of visual distinction.

    Or use richtextbox for formatting control.

  7. Anonymous users2024-02-01

    There are two ways to do it:

    1 Alignment with tab t.

    When the tab t is output, the output cursor is moved to achieve the alignment effect. Therefore, you can add t to the corresponding position of the output to achieve alignment.

    It is required that the output of the same column in each row should not be too different.

    2 Add a usage width control number to the format character.

    When C uses printf output, each control character can be written.

    NC forms, such as %10d, %12f, %8c, %16s, etc.

    The effect is that the width of n characters is taken up when the corresponding variable is output. Fill in the space to the left of the insufficient part. In this way, the right alignment effect can be achieved.

    If you want to achieve the alignment effect, you only need to add the - sign before the width character, such as %-8s, that is, the string is output, accounting for 8 bits of width, and filling in the space on the right.

  8. Anonymous users2024-01-31

    No, there can be shortcuts.

  9. Anonymous users2024-01-30

    ctrl+e。Then press d to make ** neat.

  10. Anonymous users2024-01-29

    ctrl+e,d to format all.

    Ctrl+E,f format the selected **.

  11. Anonymous users2024-01-28

    Simple, just direct +.

    string a="aaa";

    string b="@";

    string c="";

    string str=a+b+c;

    In the end, str is it.

  12. Anonymous users2024-01-27

    I haven't encountered it, just set the value of the righttoleft property to yes. Maybe you have a lot of spaces behind your text that makes it visually centered, and then carefully find out why, and if it doesn't work, create a form to try it out.

Related questions
5 answers2024-04-06

Add a field in Table 1 as a foreign key and Billno in Table 2 >>>More

11 answers2024-04-06

Valid character constants are:

a.'084' is not legal, there is no 8 in octal. >>>More

10 answers2024-04-06

There is no difference between a string and an array of characters. >>>More

7 answers2024-04-06

The string is immutable, and the list is mutable.

That is to say, once the meaning of the string is determined, it cannot be changed, but the list can. >>>More

3 answers2024-04-06

Strange indeed, the result of my experiment is that if the string variable is initialized first, the subscript can be used to read and write the string variable normally. >>>More