我需要帮助使用C#
为Dynamics NAV创建CtrlAddIn我对matrix和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);
}
我需要将行和列的总数添加为TotalRoles和TotalOperations,我需要将水平和垂直方向的文本框的最后位置传递给动态,+ 1以获得正确的位置。我怎样才能做到这一点?欢迎任何帮助。感谢
答案 0 :(得分:0)
控件加载项应该与Visual Studio中的自定义控件呈现相同,但是可能会应用一些默认边距。检查您的文本框中是否设置了margin property,以明确将其设置为零。
此外,将控件放在更好的容器中,例如Panel,TableLayoutPanel或FlowLayoutPanel。这些更专业的控件应该可以更容易地安排子元素,而无需手动计算位置等。
RTC中的矩阵表单
Dynamics NAV已经能够显示矩阵式表单 - 是否有一个特定的用例,其中自定义矩阵插件更适用?将客户端控件加载项DLL分发给所有用户可能很难调试和维护。
有walkthroughs on MSDN解释了将经典Matrix表单迁移到RTC客户端的过程,如果这是您的基本目标。