1. Use of ComboBox:
1) Clear Items: mComShift-> Items-> Clear ();
2) events are often used: OnDropDown (triggered when the drop-down box is selected) and OnChange (triggered after the drop-down box is selected)
3) data loading in the drop-down box: you can load data in the OnDropDown event, or load data in FormCreate. The preceding method is recommended,
Because when the related data is changed in other forms, if it is FormCreate, the data in the drop-down box will not change.
4) There are two methods to bind data to the drop-down box. The following describes how to use mComShift as the name of the drop-down box:
1. mComShift-> Items-> AddObject (ADOQuery_Local1-> FieldByName ("schedulename")-> AsString,
(TObject *) ADOQuery_Local1-> FieldByName ("scheduleid")-> AsInteger );
Second: mComShift-> Items-> AddObject (ADOQuery_Local1-> FieldByName ("schedulename")-> AsString,
New TValue (ADOQuery_Local1-> FieldByName ("scheduleid")-> AsString ));
If the second method is used, the following conversions are required:
Class TValue: public TObject
{
Public:
TValue (const AnsiString & value): mValue (value ){}
AnsiString mValue;
};
5) obtain the selected data from the drop-down list: AnsiString scheduleid = (TValue *) mComShift-> Items-> Objects [mComShift-> ItemIndex])-> mValue;
6) default value of the drop-down box initialization: mComShift-> ItemIndex = 0; // select the first data
2. Prompt message: ShowMessage ("message ");
3. Data type conversion:
1) int-AnsiString: int I = 1; AnsiString j = IntToStr (I );
2) AnsiString-int: I = j. ToInt ();
4. C ++ Builder 6 Environment usage:
1) F9 is the debugging start, F8 is the line-by-line debugging, and Run-Program Reset is the end of the debugging.
2) The Object Inspector is the attribute view of each control, and the Object TreeView can clearly display all the controls in this form.
5. Pay attention to the class initialization parameters, such as CTShift * shift = new CTShift (ShiftID, Shiftname, "", StartTime, EndTime, 0 ).
The order must be correct.
6. Oracle
1) query the data of a table in the previous days: select scheduleid, schedulename from wf_schedule where rownum <= 10
2) The error "Violation of unique constraints" indicates that when a table has one or more primary keys, this problem occurs when the table has data and inserts the same data as the primary key.
3) delete a TABLE field: alter TABLE wf_shift drop column SelectFlag;
7. When the program runs abnormally (especially), you may wish to re-Build All Projects (one or multiple times) or re-open the program.
8. Log printing:
1) The files are: tlog. h and tlog. cpp.
2) g_logFile.open (); TLog g_logFile ("WorkForce", "1.0", 1); g_logFile.print ("log"); g_logFile.close ();
9. Use of ListBox:
1) dynamically load data: ListBox_NoSelectShift-> Items-> AddObject (shiftname, new TValue (query-> FieldByName ("shiftid")-> AsString ));
2) determine the selected item and retrieve the Name and Id
For (int I = 0; I <ListBox_NoSelectShift-> Count; I ++)
{
If (ListBox_NoSelectShift-> Selected [I])
{
AnsiString id = (TValue *) ListBox_NoSelectShift-> Items-> Objects [ListBox_NoSelectShift-> ItemIndex])-> mValue;
AnsiString name = ListBox_NoSelectShift-> Items-> Strings [I];
ListBox_SelectShift-> Items-> AddObject (name, new TValue (id ));
ListBox_NoSelectShift-> Items-> Delete (I );
}
}
10. Execute SQL statements (there are no more than two types), which are applicable to the system and directly called instances:
1) Non-query:
AnsiString mySql = "";
DM-> ExecSql (mySql );
2) query:
AnsiString strSql = "";
TADOQuery * query = DM-> ADOQuery_Comm;
Query-> SQL-> Clear (); query-> SQL-> Add (strSql );
Query-> Open (); query-> First ();
While (! Query-> Eof)
{
Int ActiveID = query-> FieldByName ("activeid")-> AsInteger;
// Read the table field www.2cto.com
Query-> Next ();
}
Query-> Close ();
11. m_pVctLstShift.push_back (NewLstShift); // push_back is used to load data.
From the loveheronly Column