Announcement

Collapse
No announcement yet.

OpenFileDialog: Dateiformat?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • OpenFileDialog: Dateiformat?

    Ich habe ein kleines Windowsformular erstellt mit einigen Komponenten und ich habe vor auf Öffnen zu klicken und dann kann ich das Dateiformat "*.att" zu öffnen. Das ist ein Format was durchs Internet-Formular erstellt wird wenn man im Internet z.b. ein Formular mit <form method="post" etc......> programmiert hat mit der jeweiligen Ziel-email-adresse. Jetzt kommt die Abgeschickte FormularDatei alt POST.ATT als E-Mail an und ich möchte mit meinem kleinen Programm diese Datei Öffnen doch ich kann nur *.rtf dateien öffnen. Wie bekomme ich das jetzt hin, das ich dieses Format öffnen kann. Muss ich was anderes als RichtextBox nehmen???
    Danke für Hilfe im vorraus...

    Gruß

    P.S.: Hier ist der Quellcode mal..

    &lt;
    /*
    * Created by SharpDevelop.
    * User: Thorsten
    * Date: 28.09.2005
    * Time: 10:22
    *
    * To change this template use Tools | Options | Coding | Edit Standard Headers.
    */
    using System;
    using System.Drawing;
    using System.Windows.Forms;

    namespace Online_Bewerbungs_Formular
    {
    /// <summary>
    /// Description of MainForm.
    /// </summary>
    public class MainForm : System.Windows.Forms.Form
    {
    private System.Windows.Forms.Button button1;
    private System.Windows.Forms.RichTextBox richTextBox1;
    private System.Windows.Forms.PrintDialog printDialog1;
    private System.Windows.Forms.OpenFileDialog openFileDialog1;
    private System.Windows.Forms.Button button2;
    public MainForm()
    {
    //
    // The InitializeComponent() call is required for Windows Forms designer support.
    //
    InitializeComponent();

    //
    // TODO: Add constructor code after the InitializeComponent() call.
    //
    }

    [STAThread]
    public static void Main(string[] args)
    {
    Application.Run(new MainForm());
    }

    #region Windows Forms Designer generated code
    /// <summary>
    /// This method is required for Windows Forms designer support.
    /// Do not change the method contents inside the source code editor. The Forms designer might
    /// not be able to load this method if it was changed manually.
    /// </summary>
    private void InitializeComponent() {
    this.button2 = new System.Windows.Forms.Button();
    this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
    this.printDialog1 = new System.Windows.Forms.PrintDialog();
    this.richTextBox1 = new System.Windows.Forms.RichTextBox();
    this.button1 = new System.Windows.Forms.Button();
    this.SuspendLayout();
    //
    // button2
    //
    this.button2.Location = new System.Drawing.Point(456, 328);
    this.button2.Name = "button2";
    this.button2.TabIndex = 2;
    this.button2.Text = "Beenden";
    this.button2.Click += new System.EventHandler(this.Button2Click);
    //
    // openFileDialog1
    //
    this.openFileDialog1.FileOk += new System.ComponentModel.CancelEventHandler(this.Open FileDialog1FileOk);
    //
    // richTextBox1
    //
    this.richTextBox1.Location = new System.Drawing.Point(8, 24);
    this.richTextBox1.Name = "richTextBox1";
    this.richTextBox1.Size = new System.Drawing.Size(520, 296);
    this.richTextBox1.TabIndex = 0;
    this.richTextBox1.Text = "";
    //
    // button1
    //
    this.button1.Location = new System.Drawing.Point(8, 328);
    this.button1.Name = "button1";
    this.button1.Size = new System.Drawing.Size(128, 23);
    this.button1.TabIndex = 1;
    this.button1.Text = "Bewerbung Öffnen";
    this.button1.Click += new System.EventHandler(this.Button1Click);
    //
    // MainForm
    //
    this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
    this.ClientSize = new System.Drawing.Size(536, 358);
    this.Controls.Add(this.button2);
    this.Controls.Add(this.button1);
    this.Controls.Add(this.richTextBox1);
    this.Name = "MainForm";
    this.Text = "OBF-Viewer version 1.0 Beta";
    this.ResumeLayout(false);
    }
    #endregion
    void Button2Click(object sender, System.EventArgs e)
    {
    Close();
    }


    void OpenFileDialog1FileOk(object sender, System.ComponentModel.CancelEventArgs e)
    {

    }

    void Button1Click(object sender, System.EventArgs e)
    {
    OpenFileDialog OD = new OpenFileDialog();

    OD.Filter = "ATT-Dokumente (*.att)|*.att|Alle Dateien(*.*)|*.*";

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

    {

    richTextBox1.LoadFile(OD.FileName);

    }

    }

    }
    }
    &gt;

  • #2
    Hi,

    es dürfte reichen im OpenFileDialog die beiden Member
    DefaultExt und Filter entsprechend zu setzen.

    Gruß
    Hors

    Comment

    Working...
    X