Use. INI file to create "Dynamic Help" for the input interface

Source: Internet
Author: User
Tags ini int size key words
Create | Dynamic in C # programming, in some cases we might be able to use it. INI file. For example, create "Dynamic Help" for an input interface:

We set a label below the input interface, and when the user moves the cursor to each textbox or other input, the label text is automatically transformed into some help information for the entry when you select the box.

INI file is a text file, consisting of several sections (section), under each parenthesized heading, a number of key words (key) and their corresponding values (value)

[Section]

Key=value


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

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

First we need to invoke the 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 a callback method for the Enter event for the input entry (such as a TextBox)

This. Yourtextbox.enter + = new System.EventHandler (this.conenter);
private void Conenter (Object sender, System.EventArgs e)
{
String strpromptfile = Directory.GetCurrentDirectory () + "\\HelpInfo.ini";//Get the path where the INI file resides

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 that displays the Help information
}




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.