combo box file name

combo box file name

k005
Advisor Advisor
1,268 Views
6 Replies
Message 1 of 7

combo box file name

k005
Advisor
Advisor

Hi all,

 

 

Filenames are available in the combo box in Form1.

 

How can I get these filenames into the dosya variable?

 

Thanks in advance for the help friend.

 

 

 [CommandMethod("IMPORTBLOCKREFS")] //dwg dosyasından blokları çeker.
        public static void ImportBlockReferences()
        {
            Form1 frm3 = new Form1();
            string blokKlasor = @"E:\Gerekli\Bloklar\";
            string dosya = blokKlasor + frm3.cmbDwgler.SelectedItem;

            Mesaj(dosya, "");


            var db = HostApplicationServices.WorkingDatabase;
            using (var sourceDb = new Database(false, true))
            {

                sourceDb.ReadDwgFile(dosya, FileOpenMode.OpenForReadAndAllShare, true, null);
....
....
....

 

 

 

0 Likes
Accepted solutions (2)
1,269 Views
6 Replies
Replies (6)
Message 2 of 7

fieldguy
Advisor
Advisor

show your "form1" code - how do you create the combo box?

0 Likes
Message 3 of 7

k005
Advisor
Advisor

1***

 

if (tabControl1.SelectedTab == tabPage5)
{
string blokklasor = @"E:\Gerekli\Bloklar";
FileInfo[] files = new DirectoryInfo(blokklasor).GetFiles("*.dwg");
//cmbDwgler.DataSource = null;
cmbDwgler.DataSource = files;

}

 

 

 

 

2 *** this call

private void btnBlcGetir_Click(object sender, EventArgs e)
{
this.Hide();
Adoc.SendStringToExecute("IMPORTBLOCKREFS\n", false, false, false);
this.Close();
}

 

 

2023-01-15_143742.png

 

 

 

0 Likes
Message 4 of 7

fieldguy
Advisor
Advisor

Make sure your form1 combo box is declared as "Public".

combobox2.png

0 Likes
Message 5 of 7

k005
Advisor
Advisor

I am sure.

 

public.png

0 Likes
Message 6 of 7

fieldguy
Advisor
Advisor
Accepted solution

Ok.  Maybe you need to add "ToString()" to your selected item.

 

Check the example at the link below.

 

https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.combobox?view=windowsdesktop-7.0#e... 

0 Likes
Message 7 of 7

k005
Advisor
Advisor
Accepted solution

I solved it with get set. Thanks for your help my friend. @fieldguy 

 

 Durum.dosyaAdiAl = cmbDwgler.SelectedItem.ToString();

 

 

0 Likes