【问题标题】:c# change the form title by the savefile name.extensionc#通过savefile name.extension更改表单标题
【发布时间】:2011-12-06 16:12:22
【问题描述】:

每次我更改 .rft 或 .txt 等文件时,我希望它在标题中显示名称,例如 RFT Editor:docment.rft

这里是我使用 atm 的代码

this.Text = "RFT Editor:" + saveFileDialog1.FileName;

希望有人能帮忙

【问题讨论】:

  • 现有代码有什么问题?
  • 您的意思是富文本文件吗?那是RTF。 RFT 是 Rational Functional Tester。

标签: c# rft


【解决方案1】:

您的问题措辞不当。你没有描述你得到的结果与你想要的结果有何不同。

我只能猜测问题是"RFT Editor:" + saveFileDialog1.FileName 为您提供了一个包含完整路径的文件名,并在您的示例中获得 "RFT Editor:docment.rft" 您需要"RFT Editor:" + System.IO.Path.GetFileName(saveFileDialog1.FileName) 代替。

【讨论】:

    【解决方案2】:

    假设你需要这个:

    ...
    ...
    
    // Save clicked inside, not Cancel
    if(saveFileDialog1.openDialog() == DialogResult.OK)
    {
        // this.Text is same as only Text - in case of current class (matter of choice)
        Text = "RTF Editor: " + savefileDialog1.FileName;
        ...
        ...
    }
    

    【讨论】:

      猜你喜欢
      • 2012-06-10
      • 1970-01-01
      • 1970-01-01
      • 2017-03-29
      • 2019-10-10
      • 1970-01-01
      • 1970-01-01
      • 2022-07-31
      • 1970-01-01
      相关资源
      最近更新 更多