控件加载项 用于 C# 中文本框(二维)的导航矩阵



>我需要帮助使用 C# 为 Dynamics NAV 创建 CtrlAddIn

我对矩阵和c#很陌生,我正在使用WinForm和VisualStudio来创建DLL。

这是代码的一部分:

地区基金会 飞行员 depuis Dynamics

    // Tout effacer
    [ApplicationVisible]
    public void CleanPanel()
    {
        MainPanel.Controls.Clear(); //Tous les elements seront effacés
    }
    // Gestion des rôles
    [ApplicationVisible]
    public void AjouterRole(string NameL, string idRoleL, int posRoleL)
    {            
        TextBox tb = new TextBox();
        //Random random = new Random();
        ToolTip TTL = new ToolTip();
        String TooltipL;
        //int randRed = random.Next(1, 255);
        //int randGreen = random.Next(1, 255);
        //int randBlue = random.Next(1, 255);
        //tb.BackColor = Color.FromArgb(randRed, randGreen, randBlue);
        tb.BackColor = Color.Bisque;
        tb.Name = idRoleL;
        //si le texte est plus grand, je mets ...
        tb.Text = NameL;
        if (tb.TextLength > 7)
        {
            string nameO = NameL.Substring(0, 7);
            string points = "...";
            tb.Text = string.Concat(nameO + points);
        }
        else
        {
            tb.Text = NameL;
        }
        tb.AllowDrop = true; //pour le drag and drop                      
        tb.Multiline = true;//pour pouvoir avoir des textboxes de taille differente
        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(70, 60);
        tb.Left = posRoleL * 70;
        tb.Visible = true;
        tb.Cursor = Cursors.Hand;
        //wrap pour que le texte n'aille pas a la ligne et tooltip pour voir le text
        TooltipL = NameL;
        tb.WordWrap = false;
        TTL.SetToolTip(tb, TooltipL);
        //evenement pour le DRAG AND DROP
        //1 Je gere le drag pour pouvoir le bouger
        tb.MouseDown += (senderL, eL) => tb.DoDragDrop(tb.Text, DragDropEffects.Move);
        tb.DragEnter += (senderL, eL) => { eL.Effect = DragDropEffects.Move; };
        //EventControlAddin(3, idRoleL.PadRight(10) + ";" + (string)posRoleL.ToString());
        //2 Je gere le drop pour pouvoir bouger le controle
        tb.DragDrop += (senderL, eL) => { tb.Text = eL.Data.GetData(DataFormats.Text).ToString(); EventControlAddin(3, idRoleL.PadRight(10) + ";" + (string)posRoleL.ToString()); };
        //evenement pour pouvoir supprimer un role
        tb.MouseEnter += IlumineRole;
        tb.MouseLeave += Eteint;
        //evenement pour modifier le role
        tb.DoubleClick += (senderL, eL) => EventControlAddin(6, tb.Name);
        MainPanel.Controls.Add(tb);
    }
    [ApplicationVisible]
    public void AjouterTotalRole(string NameL, string idRoleL, int posRoleL, string dureeL, string coutL)
    {            
        // Textbox
        TextBox tb = new TextBox();
        tb.Name = idRoleL;
        tb.Text = NameL;
        int indexMaxRoles = 99;//somme de toutes les lignes + 1 
        // Je dois mettre un tooltip pour comprendre
        ToolTip TTL = new ToolTip();
        String TooltipLCout = "Totaux des rôles en durée et en coût.";
        //Panel contenant les labels
        Panel pn = new Panel();
        pn.Size = new Size(70, 60);
        pn.BackColor = Color.Azure;
        pn.BorderStyle = BorderStyle.FixedSingle;
        pn.Left = posRoleL * 70;
        pn.Top = indexMaxRoles + 1; //Il faut qu'il soit a la casse finale
        Label lb_Duree = new Label();          
        lb_Duree.Text = "Durée:" + dureeL;
        //lb_Duree.Width = 60;
        Label lb_Cout = new Label();
        lb_Cout.Text = "Coût:" + coutL;
        //lb_Cout.Width = 60;
        lb_Cout.Top = 20;
        TTL.SetToolTip(pn, TooltipLCout);
        pn.Controls.Add(lb_Duree);
        pn.Controls.Add(lb_Cout);
        MainPanel.Controls.Add(pn);
    }

我需要将行和列的总和添加为总角色和总操作,并且我需要将文本框在水平和垂直方向的最后一个位置传递给动态,+ 1 以获得正确的位置。我该怎么做?任何帮助最受欢迎。谢谢

控件外接程序的呈现方式应与 Visual Studio 中的自定义控件相同,但可能会应用一些默认边距。检查文本框上的边距属性是否设置为显式设置为零。

此外,将控件放在更好的容器中,例如 Panel、TableLayoutPanel 或 FlowLayoutPanel。这些更专业的控件应该可以更轻松地排列子元素,而无需手动计算位置等。

RTC 中的矩阵形式

Dynamics NAV 已经能够显示矩阵样式的表单 - 是否有自定义矩阵加载项更适用的特定用例?将客户端控件外接程序 DLL 分发给所有用户可能难以调试和维护。

MSDN 上有演练,其中解释了将经典矩阵表单迁移到 RTC 客户端的过程(如果这是您的基本目标)。

最新更新