Skip to Content

OpenFileDialog Focus Problem

When making a functionally attachment in my Add-on, sometimes using the property of the OpenFileDialog C #, the dialog box that appears to select files is behind the screen of the sap. That is, it loses focus. How to do this by setting it as the main focus in sap? Here my code:

ThreadStart starter = delegate { Anexar(oEditItem); };

Thread t = new Thread(starter);

t.SetApartmentState(ApartmentState.STA);

t.Start();

t.Join();

public void Anexar(SAPbouiCOM.EditText oEditItem)

{

try

{

OpenFileDialog fDialog = new OpenFileDialog();

fDialog.Title = "Anexar arquivo";

fDialog.Filter = "(.)|.";

fDialog.InitialDirectory = @"C:\";

if (fDialog.ShowDialog() == DialogResult.OK)

{

oEditItem.Value = fDialog.FileName.ToString();

}

}

catch (Exception e)

{

SBO_Application.MessageBox(e.Message);

}

}

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Best Answer
    Posted on Dec 08, 2011 at 04:10 AM
    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.