I would like to create SaveFileDialog
with default file name
from value DataGridViewCells
So far I tried
private void buttonSave_Click(object sender, EventArgs e)
{
//first
//mySaveFileDialog.FileName = myDataGridView.SelectedCells[2].Value.ToString();
//second
SaveFileDialog saveFile = new SaveFileDialog();
saveFile.FileName = myDataGridView.SelectedCells[2].Value.ToString();
saveFile.ShowDialog();
}
Can anyone help me solve this?
The SaveFileDialog
has a property intended for this purpose: DefaultFileName
using Silverlight or FileName
using .NET
Your (uncompilable) code from the question would become:
private void buttonSave_Click(object sender, EventArgs e)
{
SaveFileDialog mySaveFileDialog = new SaveFileDialog();
//Silverlight
mySaveFileDialog.DefaultFileName = myDataGridView.SelectedCells[2].Value.ToString();
//.NET
mySaveFileDialog.FileName = myDataGridView.SelectedCells[2].Value.ToString();
}