Windows Develop Bookmark and Share   
 index > Windows Forms Designer > Custom SaveAs Dialog
 

Custom SaveAs Dialog

Hi

I had made a little application that can save data in ASCII or Binary format. I wish to let user choose the format at runtime. But I read the it's impossible to extend the SaveDialog control in the .Net Framework. And I don't find a way to add a radio button to let user choose the format.

Is someone know a way to do something like this? Or maybe there is already a custom made control that do this somewhere on the Internet.

Thank you
Esquif  Tuesday, July 26, 2005 7:51 PM
So that to be complicated the life?

I understand that you wish to use radiobuttons to choose the format to keep, but the SaveDialog allows you to specify the elements that you wish to store in the drop-down list of formats.



[Visual Basic]
Protected Sub button1_Click(sender As Object, e As System.EventArgs)
    Dim myStream As Stream
    Dim saveFileDialog1 As New SaveFileDialog()
   
    saveFileDialog1.Filter = "txt files (*.txt)|*.txt|Bin files (*.bin)|*.bin"
    saveFileDialog1.FilterIndex = 2
    saveFileDialog1.RestoreDirectory = True
   
    If saveFileDialog1.ShowDialog() = DialogResult.OK Then
        myStream = saveFileDialog1.OpenFile()
        If Not (myStream Is Nothing) Then
            'Code to write the stream goes here
            myStream.Close()
        End If
    End If
End Sub

 




[C#]
protected void button1_Click(object sender, System.EventArgs e)
 {
     Stream myStream ;
     SaveFileDialog saveFileDialog1 = new SaveFileDialog();
 
     saveFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.bin)|*.bin"  ;
     saveFileDialog1.FilterIndex = 2 ;
     saveFileDialog1.RestoreDirectory = true ;
 
     if(saveFileDialog1.ShowDialog() == DialogResult.OK)
     {
         if((myStream = saveFileDialog1.OpenFile()) != null)
         {
             //Code to write the stream goes here.
             myStream.Close();
         }
     }
 }

 


Another alternative that you have is to create your own window to save, and to invoke it when the user chooses the respective command.

Regards
Tabas  Tuesday, July 26, 2005 10:41 PM

You can use google to search for other answers

Custom Search

More Threads

• hosting compact fraework from in windows form designer
• Designer Generated Code: SizeF
• Property To save toolstripbutton
• How add a Column In DataGridView
• Toolstrip buttons arent visible
• Don't want design mode
• get events of an object declared in code
• How can I Extend Child Controls of an Extended Control
• Form designer error
• get template of a document