Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/280.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 启动pn.Scroll()时移动面板_C#_Winforms_Panel - Fatal编程技术网

C# 启动pn.Scroll()时移动面板

C# 启动pn.Scroll()时移动面板,c#,winforms,panel,C#,Winforms,Panel,我有一个面板MainPanel,其中包含两个面板pncontrolles(水平滚动)和pnContOperations(垂直滚动)。每个都有不同的大小和位置。我有另一个面板pncrossion,我把它作为默认设置放在pnContOperations中。我想将pncrossion从pnContOperations更改为pncontrols。这必须随pncross的大小和位置的变化而变化。所有这些都是为了能够在滚动pncontrols或pnContOperations时相应地移动pncrossion

我有一个面板
MainPanel
,其中包含两个面板
pncontrolles
(水平滚动)和
pnContOperations
(垂直滚动)。每个都有不同的大小和位置。我有另一个面板
pncrossion
,我把它作为默认设置放在
pnContOperations
中。我想将
pncrossion
pnContOperations
更改为
pncontrols
。这必须随
pncross
的大小和位置的变化而变化。所有这些都是为了能够在滚动
pncontrols
pnContOperations
时相应地移动
pncrossion
。在每个面板中,控件都是文本框(如果有必要的话)


我找到了解决方案,我编辑了上面的代码来显示。我用2个标准的PnTimeStCurle和PnTimeScTcess和2个文本框,TB和TbCopy.对于我的问题,我只需要在拖动时执行相同的操作。并更新文本框、文本和位置。是的,我现在很高兴

先删除,然后添加到另一个面板。它不能有两个父母。我编辑了我的问题@DonBoitnott,谢谢,我从pnContOperations中删除并将其添加到pnContRoles中,但它不起作用。位置和尺寸都不好。如果我改变交叉点的大小和位置,它就会消失。也许我也必须删除它里面的文本框,然后添加所有内容…它需要移动吗?两个相同的设置如何,并根据需要隐藏/显示它们?再抚养孩子的控制措施充其量也是笨重的。我将在大小、位置和父母方面做两项不同的工作。我将根据需要从一个文本框中删除文本框并添加到另一个文本框中。我将在稍后发布可能的解决方案…这能起作用吗?目前它不起作用。我编辑了代码。将在pnIntersectRoles和pnIntersectOperations中生成的文本框是相同的。也许我也需要复印件?
TextBox tb = new TextBox();
        TextBox tbCopy = new TextBox();
        ToolTip TTL = new ToolTip();
        String TooltipL;

        tb.BorderStyle = BorderStyle.Fixed3D;
        tb.Name = idRoleL + idOperationL.ToString();
        tb.Text = valeurL;
        tb.TextAlign = HorizontalAlignment.Right;
        tb.ScrollBars = ScrollBars.None; //pour enlever les scrollbars dans tout les textboxes
        tb.HideSelection = true;//pour ne pas avoir le focus dans le precedent textbox
        tb.Size = new Size(100, 20);
        tb.Location = new Point((posRoleL - 1) * 140 + 20 + 2, (posOperationL - 1) * 40 + 10 + 2);
        tb.Visible = true;
        tb.Cursor = Cursors.IBeam;
        tb.WordWrap = false;

        tbCopy.BorderStyle = BorderStyle.Fixed3D;
        tbCopy.Name = tb.Name;
        tbCopy.Text = tb.Text;
        tbCopy.TextAlign = HorizontalAlignment.Right;
        tbCopy.ScrollBars = ScrollBars.None; //pour enlever les scrollbars dans tout les textboxes
        tbCopy.HideSelection = true;//pour ne pas avoir le focus dans le precedent textbox
        tbCopy.Size = new Size(100, 20);
        tbCopy.Location = tb.Location;
        tbCopy.Visible = true;
        tbCopy.Cursor = Cursors.IBeam;
        tbCopy.WordWrap = false;

        TooltipL = "Veuillez écrire des numéros decimals positifs, merci.";            
        TTL.SetToolTip(tb, TooltipL);

        #endregion

        #region EVENEMENTS TEXTBOX
        //Evenement quand le text change(si le texte quand écrit ce sont des numéros positif)            
        tb.Leave += (senderL, eL) =>
        {
            string patron = @"^[0-9]*\.?[0-9]*$";
            string input = tb.Text;
            Match m = Regex.Match(input, patron);

            if (m.Success)
            {
                EventControlAddin(5, (string)idOperationL.ToString().PadRight(10) + ";" + idRoleL.PadRight(10) + ";" + (string)tb.Text);
            }
            else
            {
                MessageBox.Show("Vous devez écrire un numéro valide et decimal positif, s'il vous plaît.");
                tb.Text = "???";
                tb.BackColor = Color.IndianRed;
                tb.Focus();
            }

        };

        #endregion            

        pnContRoles.Scroll += (senderL, eL) =>
        {                
            pnContRoles.BringToFront();               
        };
        pnContOperations.Scroll += (senderL, eL) =>
        {   
            pnContOperations.BringToFront();
        };            

        #region AJOUTS

        pnIntersectRoles.Location = new Point(0, 40);
        pnIntersectRoles.Size = new Size(nRolesG * 140, 320);
        pnIntersectRoles.Parent = pnContRoles;

        pnIntersectRoles.Controls.Add(tbCopy);
        pnContRoles.Controls.Add(pnIntersectRoles);
        MainPanel.Controls.Add(pnContRoles); 

        pnIntersectOperations.Location = new Point(220, 0);
        pnIntersectOperations.Size = new Size(840, (nOperationsG + nPhasesG) * 40);
        pnIntersectOperations.Parent = pnContOperations;

        pnIntersectOperations.Controls.Add(tb);
        pnContOperations.Controls.Add(pnIntersectOperations);
        MainPanel.Controls.Add(pnContOperations);