2
命令行中的字符串格式非常好,但在帶有標籤的gui中,它全部關閉。我覺得我的格式是正確的字符串格式不正確
例子:
代碼:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace DisplayMultiplicationTableGUI
{
public partial class Form1 : Form
{
int i, j;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
label1.Text = String.Format("{0,3}", " ");
for (i = 1; i <= 10; i++)
label1.Text += String.Format(" {0,3}", (i).ToString());
for (i = 1; i <= 10; i++)
label2.Text += String.Format("\n{0,3} ", (i).ToString());
for (i = 1; i <= 10; i++)
{
for (j = 1; j <= 10; j++)
label3.Text += String.Format("{0,3} ", (i*j).ToString());
label3.Text += String.Format("\n");
}
}
}
}
}
或者使用實際的網格。 – Blorgbeard
是的,那也可以。 –