Visual Basic Code , VB.NET Code, VB Code
  Home   :  Code   :  Forums   :  Submit   :  Mailing List   :  About   :  Contact


Control Array


Control Array

Author
Message
shers
shers
Forum God
Forum God (16K reputation)Forum God (16K reputation)Forum God (16K reputation)Forum God (16K reputation)Forum God (16K reputation)Forum God (16K reputation)Forum God (16K reputation)Forum God (16K reputation)Forum God (16K reputation)

Group: Forum Members
Posts: 66, Visits: 170
Hi,

I'm working on C# with COM. I have a COM OLE control that I wish to create on the form as control array during runtime, as the number of cotrols depends on the number of files in the corresponding folder. How do I go about it? I'm attaching a pic of the form as to how I want it to be.

Thanks

Attachments
snap.jpg (925 views, 91.00 KB)
shers
shers
Forum God
Forum God (16K reputation)Forum God (16K reputation)Forum God (16K reputation)Forum God (16K reputation)Forum God (16K reputation)Forum God (16K reputation)Forum God (16K reputation)Forum God (16K reputation)Forum God (16K reputation)

Group: Forum Members
Posts: 66, Visits: 170
Looks like I have solved the issue. Here is the code.

private void TV_AfterSelect(object sender, TreeViewEventArgs e)
        {
            btnPrev.Enabled = false;
            btnNext.Enabled = false;

            TreeNode newSelected = e.Node;
            DirectoryInfo nodeDirInfo = (DirectoryInfo)newSelected.Tag;

            int numFile = 0;

            this.groupBox2.Controls.Clear();

            sldNum = nodeDirInfo.GetFiles("*.sld").Count();
            ShowSld();

            foreach (FileInfo file in nodeDirInfo.GetFiles("*.sld"))
            {
                     numFile++;
                    sldArray[numFile].FileName = file.FullName;
             }
        }

        private void ShowSld()
        {
            int xPos = 10;// 140;
            int yPos = 23;// 140;
            AddControls("sld", sldNum); //Create slides.
            int n = 1;
            while (n < sldNum + 1)
            {
                sldArray[n].Tag = n;
                sldArray[n].Width = 125;
                sldArray[n].Height = 115;
                if (xPos > 570)
                {
                    xPos = 10;
                    yPos = yPos + sldArray[n].Height + 28;
                }
                sldArray[n].Left = xPos;
                sldArray[n].Top = yPos;
                xPos = xPos + sldArray[n].Width + 15;
                groupBox2.Controls.Add(sldArray[n]);
                n++;
            }
        }

        private void AddControls(string anyControl, int cNumber)
        {
            switch (anyControl)
            {
                case "sld":

                    sldArray = new AxSLIDELib.AxSlide[cNumber + 1];
                    for (int i = 0; i < cNumber + 1; i++)
                    {
                        sldArray[i] = new AxSLIDELib.AxSlide();
                    }
                    break;

            }
        }      

But my next problem is, if there are more than 15 files in the folder, how do I display it in the form using the Previous and Next button?

Thanks

GO


Similar Topics


Reading This Topic


Login
Existing Account
Email Address:


Password:


Social Logins

Select a Forum....

















A1VBCode Forums


Search