wanting to right click within FileListBox and change Form title text to selected file.

how do I access the title bar of the frmTest below thx. -greg

namespace TestExplorer

{

public class frmTest : System.Windows.Forms.Form

private void fileListBox1_MouseClick(object sender, MouseEventArgs e)

{

frmTest. = this.fileListBox1.SelectedItem.ToString;

}



Answer this question

wanting to right click within FileListBox and change Form title text to selected file.

  • Hoopla

    thanks for sticking with me here Brendan! I had that at one point......but..nevermind....we got it..!


  • thomas woelfer

    The Text property gives you access to the window caption on a Windows form.

  • Harrywu

    <slapping self> I goofed and forgot to mention something from your first example...

    frmTest is the name of the class (the type) and not a reference to the instance of the type.

    Instead of:

    frmTest.Text = "hello"

    change it to

    this.Text = “hello”

    In C# the keyword ‘this’ refers to the class that the current code is executing within.



  • Brians_224

    Thank you Brendan.

    When do the following, I get the following error on the fine that contains frmTest.Text

    private void fileListBox1_MouseClick(object sender, MouseEventArgs e){

    frmTest.Text = "hello";

    }

    Error 1 An object reference is required for the nonstatic field, method, or property 'System.Windows.Forms.Control.Text.get' C:\protos\windows explorer in a user control\ExplorerTreeSource\Demo Project\frmTest.cs 332 12 TestExplorer


  • wanting to right click within FileListBox and change Form title text to selected file.