Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenFileDialog cuts off pre-populated file name [duplicate]

Tags:

c#

.net

I use the following to display an Open File dialog:

OpenFileDialog fdlg = new OpenFileDialog();
fdlg.FileName = Properties.Settings.Default.Last_competition_file;
fdlg.Filter = "FS database files (*.fsdb)|*.fsdb|All files (*.*)|*.*";
fdlg.FilterIndex = 0;
if (fdlg.ShowDialog(this) == DialogResult.Cancel) return false;

(Properties.Settings.Default.Last_competition_file contains the whole path to the last file)

Problem: For a file name "c:\data\nationals_2014.fsdb", the File name field only shows "ionals_2014.fsdb".

When clicking into the File name field, and moving the cursor to the left, the remainder of the file name & path re-appears. But I'm looking for a way to make the whole file name visible from the beginning.

Note that this is not a length issue. I also tried setting path and file name separately (through OpenFileDialog.InitialDirectory), but even then only the tail end of the (now much shorter) file name was displayed.

Any ideas how to get the Open File dialog to show the full pre-populated file name from the beginning?

like image 893
JoergEwald Avatar asked Jul 02 '14 07:07

JoergEwald


1 Answers

Caveat: This is a Kludge, not a real answer.

  OpenFileDialog fdlg = new OpenFileDialog();
  fdlg.FileName = Properties.Settings.Default.Last_competition_file;
  fdlg.Filter = "FS database files (*.fsdb)|*.fsdb|All files (*.*)|*.*";
  fdlg.FilterIndex = 0;
  fdlg.ShowHelp = true;
  fdlg.HelpRequest +=  new System.EventHandler(HelpRequested); ;
  if (fdlg.ShowDialog(this) == DialogResult.Cancel) return false;

private void HelpRequested(object sender, EventArgs e)
{
    MessageBox.Show(".. is no Help", "There..");
}

The style of the Dialog reverts to an older incarnation.

Shrug. Some workarounds make me wonder about many things..

like image 95
TaW Avatar answered Oct 19 '22 22:10

TaW