Use the .ini file to create "Dynamic Help" as the input interface

xiaoxiao2021-03-06  73

In C # programming, in some cases we may also use .ini files. For example, create a "Dynamic Help" for an input interface: We set a label below the input interface, when the user moves the cursor to each TextBox or other input, select some of the help information to the input item. The INI file is a text file, which is composed of several sections. Here's a keyword (key) and its corresponding value in each tomb of each with brackets (Value).

[Section]

Key = Value

Our INI file is relatively simple, the file name is: Helpinfo.ini. ----------------- [Promptinfo] YourTextbox = Please enter xxxxx information.

-----------------

First we want to call kernel32.dll with the following statement

[DLLIMPORT ("kernel32")] Private static extern int GETPRIVATEPROFILESTRING (String Section, String Key, String DEF, STRINGBUILDER RETVAL, INT SIZE, STRING FILEPATH);

Then write to a callback method this.YourTextBox.Enter entry (e.g., the TextBox a) Enter event of a = new System.EventHandler (this.conEnter); private void conEnter (Object sender, System.EventArgs e) {string strPromptFile = Directory .Getcurrentdirectory () "//helpinfo.ini";// getting the path where the INI file is

string strClsName = sender.GetType () ToString () ToUpper ();.. if (strClsName.EndsWith ( "TEXTBOX")) {if (sender.Equals (YourTextBox)) {GetPrivateProfileString ( "PromptInfo", "YourTextBox", " ", strpromptcontent, 1024, strpromptfile;} txthelpcontent.text = strpromptcontent.tostring (); // txtHelpContent is the label of displaying help information}

转载请注明原文地址:https://www.9cbs.com/read-86768.html

New Post(0)