小编wil*_*ace的帖子

对包含坐标x和y的List <String>进行排序

任何人都可以请帮我排序以下字符串列表:

List < String >包含坐标

[0]"0 0"
[1]"0 1"
[2]"0 2"
[3]"0 3"
[4]"1 1"
[5]"1 2"
[6]"1 3"

虽然它可能并不总是那样,我想通过排序/排序来确定它(按X坐标ASC排序,然后按Y坐标ASC排序)

我试过这个,但它根本没有改变名单?- 见下文

boardObjectList.OrderBy(p => (p.Split())[0]).ThenBy(p=> (p.Split())[1]);

有任何想法吗?

谢谢,
JP

c# sorting string split list

3
推荐指数
1
解决办法
2162
查看次数

C#Panel.Refresh()不调用paint方法

我试图调用panel1 paint方法用橙色线重新绘制面板(它用蓝线启动).

我已经尝试过invalidate(),update()和refresh(),但似乎没有任何东西可以调用panel1的paint事件......

paint事件处理程序已添加到panel1:

this.panel1.Paint += new System.Windows.Forms.PaintEventHandler(this.panel1_Paint);
Run Code Online (Sandbox Code Playgroud)

有人可以帮忙吗?

static class Program
{
    /// <summary>
    /// The main entry point for the application.
    /// </summary>
    [STAThread]
    static void Main()
    {
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);

        Form1 testForm = new Form1();
        Application.Run(testForm);

        testForm.drawNewLine();
    }
}
Run Code Online (Sandbox Code Playgroud)
public partial class Form1 : Form
{
    bool blueLine = true;
    bool orangeLine = false;

    public Form1()
    {
        InitializeComponent();
    }

    private void panel1_Paint(object sender, PaintEventArgs e)
    {
        Graphics g = e.Graphics;

        if (blueLine == true)
        {
            Pen bluePen …
Run Code Online (Sandbox Code Playgroud)

c# panel .refresh repaint

2
推荐指数
1
解决办法
1万
查看次数

标签 统计

c# ×2

.refresh ×1

list ×1

panel ×1

repaint ×1

sorting ×1

split ×1

string ×1