private void llAddFootnoteInSelectedVariable_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            PxVariable pxVariable = (PxVariable)lbVariables.SelectedItem;

            if (pxVariable != null)
            {
                var variableFootnoteArray = (from vf in pxVariable.VariableFootnotes
                                             select vf).ToArray();
                FootnoteDialog frmFootnote = new FootnoteDialog();

                frmFootnote.Context = pxVariable;

                //TODO a better solution for Footnote
                pxVariable.Footnote = "B";

                if (variableFootnoteArray.Count() == 0)
                {
                    PxVariableFootnote variableFootnote = (PxVariableFootnote)CreateVariableFootnote(pxVariable);
                    variableFootnoteArray = (from vf in pxVariable.VariableFootnotes
                                             select vf).ToArray();
                }
                frmFootnote.SetDataSource((PxFootnote[])variableFootnoteArray);

                frmFootnote.AddFotnoteHandler     = CreateVariableFootnote;
                frmFootnote.RemoveFootnoteHandler = RemoveVariableFootnote;
                frmFootnote.ShowDialog();
            }
            else
            {
                MessageBox.Show("Select a content and a variable first!");
            }
        }
        public PxVariableFootnote CreateVariableFootnote(PxObject context)
        {
            PxVariableFootnote vf = new PxVariableFootnote();

            vf.FootnoteNo = FootnoteNo;
            FootnoteNo++;
            vf.FootnoteText        = "Shenim i ri";
            vf.FootnoteTextEnglish = "New Footnote";
            vf.MandOption          = "O";
            vf.ShowFootnote        = "B";
            vf.IsNew = true;
            ((PxVariable)lbVariables.SelectedItem).VariableFootnotes.Add(vf);
            ((PxVariable)lbVariables.SelectedItem).MarkAsDirty();
            _table.MarkAsDirty();
            return(vf);
        }