小编men*_*dez的帖子

如何在C#中更改form1的标题或名称

我有一个快速的问题.如何在我的应用程序中更改form1的名称?每当我尝试使用属性重命名它时,表单就会破碎,我再也无法使用它了.有没有办法在运行期间更改它或我做错了属性?谢谢.

c# winforms

5
推荐指数
2
解决办法
3万
查看次数

如何使一个keygen在C#中每隔四个字母写" - "

我有一个快速的问题.我有一个keygen为我的应用程序生成随机密码.它会生成大写字母和数字,但我希望它像某些程序一样格式化它们的代码xxxx-xxxx-xxxx.到目前为止我的代码就是这个

Random random = new Random(0);

private void button1_Click(object sender, EventArgs e)
{
    textBox1.Text = getrandomcode();
}

public string getrandomcode()
{
    char[] tokens = {'0', '1', '2', '3', '4', '5', '7', '8', '9', 'A', 'B', 'C', 
        'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
        'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};

    char[] codeArray = new char[24];

    for (int i = 0; i < 24; i++)
    {
        int index = random.Next(tokens.Length …
Run Code Online (Sandbox Code Playgroud)

c# string random password-protection key-generator

4
推荐指数
1
解决办法
893
查看次数

如何在C#中执行ALT + TAB sendkey事件

我试图使用一个包含ALT键的sendkey事件,然后按下TAB键.你是如何进行这一行动的,我尝试了很多变化,但我似乎无法找到答案,谢谢.

c# keyboard tabs sendkeys alt

4
推荐指数
2
解决办法
2万
查看次数

你如何从C#中的保存文件对话框中保存?

这是我目前用于使用openfiledialog打开文件的代码

    private void openToolStripMenuItem_Click_1(object sender, System.EventArgs e)
    {
        //opens the openfiledialog and gives the title.
        openFileDialog1.Title = "openfile";
        //only opens files from the computer that are text or richtext.
        openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
        //gets input from the openfiledialog.
        if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
        {
            //loads the file and puts the content in the richtextbox.
            System.IO.StreamReader sr = new
   System.IO.StreamReader(openFileDialog1.FileName);
            richTextBox1.Text = (sr.ReadToEnd());
            sr.Close();`                                                                                               here is the code I am using to save through a savefiledialog          `   

    Stream mystream; …
Run Code Online (Sandbox Code Playgroud)

c# text save text-files savefiledialog

1
推荐指数
1
解决办法
2万
查看次数