荔园在线

荔园之美,在春之萌芽,在夏之绽放,在秋之收获,在冬之沉淀

[回到开始] [上一篇][下一篇]


发信人: Dreamer (我爱萤火虫), 信区: SoftDev
标  题: 【BCB】C++ Builder 经验总结
发信站: 荔园晨风BBS站 (Sat May  8 14:32:51 2004), 站内信件

一.DatePickTime控件与ToolButton与Bitton的关系:

1.date 的Format属性:yyyy-MM-dd 只能使它输完后的格式为:都是两个数的格式

2.ToolButton,只有将Date中的数值输完之后,,才能正确得到结果,不然,只有
下次,才能得到正真的结果。
3.Bitton则不会,,可直接得到结果。



二.将表的内容存入txt.txt 文本中.

TStringList *pList=new TStringList();
ADOQuery1->First();

while(!ADOQuery1->Eof)
{
pList->Add(ADOQuery1->Fields->Fields[0]->AsString+"\t"+ADOQuery1->Fields
->Fields[1]->AsString);
ADOQuery1->Next();
}

pList->SaveToFile("c:\\lvtao.txt");

delete pList;



三.取得字段的方法.

1.ADOQuery1->Fields->Fields[N]->AsString;// 可以获取任何类型
2.ADOQuery1->FieldByName("fieldname")->Value;
3.ADOQuery1->FieldValues["FieldName"];

FieldByName[].asString
4.得到字段名:
Query1->Fields->Fields[0]->FieldName;第一个字段
Query1->Fields->Fields[1]->FieldName;第二个字段
Query1->Fields->Fields[2]->FieldName;第三个字段
5.得到字段的数量:
ADOQuery1->FieldCount;



四.日期比较.

1. date1='2002-5-8' ;date2='2002-9-7';
date1<date2 (true) ;

2.在SQL 中,curdte between date1 and date2 ? 中
date1<date2( 为必须的,不然会没有记录可查寻)



五.BCB中常用的函数.


1.字符串函数:
去掉前后的空格:Trim(AnsiString) ,RTrim(String),LTrim(String).


2.日期函数:
FormatDateTime("YYYY-MM-DD",TDate);

3.数值函数:
float( ) 强型转换换。



六.表单的框架设计.

1.为了使表单,布局美观,故放在上面的控件,不能挪动。
1.放一个statice_boll. (状态栏)
2.将FORM 的autosize=false ;(至关重要,不然,结果不会尽人意)//不然,当
最小化时,再最大化时,会乱看哦,
AutoScroll=fales; 自动出现滚动----》边框。
2.还要将form 的borderstyle=single :maxbutton=false; (让窗口不能拖动,并去
掉最大化按钮,以免窗口变形)
3.最好在表单上,放些panel ,容器。 便于布局。
4.将一个panel的aligne=top 将它最顶部对齐。(不要将它的autosize=true,以免
会变掉)
5.将一个panel的aligne=Buttop 将它最下部对齐(不要将它的autosize=true,以
免会变掉)
6.再将一个panel放在中部作分格栏。(可以将)
7.



七.通过Sender访问

1.((TButton *)Sender)->Caption = "New Cpation";
注:将其强型转换为TButton 类型。


2.void __fastcall TForm1::FormCreate(TObject *Sender)
{
for(int i = 0; i < Form1->ComponentCount; ++i)
{
if (Form1->Components[i]->ClassType() == __classid(TEdit))
{
LONG Style = GetWindowLong((dynamic_cast<TEdit
*>(Form1->Components[i]))->Handle, GWL_STYLE);
SetWindowLong((dynamic_cast<TEdit *>(Form1->Components[i]))->Handle,
GWL_STYLE, Style | ES_NUMBER);
}
}
}



八.Locate 的使用。

TLocateOptions lp;
lp.Clear();
lp<<loPartialKey;
Variant l[3];
l[0]=a->Text;
l[1]=b->Text;
//"口袋" ;
l[2]="口袋" ;
//ADOQuery1->Locate("error_code;error_descrip",VarArrayOf(l,2),lp);

注:VarArrayOf(VarGroup,所返回的个数) ,
lp为,选项:
enum TLocateOption { loCaseInsensitive, loPartialKey };

typedefSet<TLocateOption, loCaseInsensitive, loPartialKey>
TLocateOptions;



九.TreeView的属性

TTreeNode *treenode=TreeView1->Selected;
1.Index.属性,表示节点在"该层"中的索引号。唯一值
2.Level属性, 表示节点所在的层,它所属的节点,都在同一层。不是唯一值。0
层所表示是根。
3.就是象用鼠标点击某个节点后的状况,但要用程序实现,不用鼠标.
TTreeNode * node = TreeView1->GetNodeAt(X,Y);
node->Selected = true;

4.for(int i=0;i<TreeView1->Items->Count;i++)
{
ShowMessage(TreeView1->Items->Item[i]->Text);
}



十.以知错误信息求解。

[C++ Error] Employee.cpp(129): E2015 Ambiguity between '_fastcall
System::Variant::operator ==(int) const' and '_fastcall System::
Variant::operator ==(const System::AnsiString &) const'



十一.PageControl的属性

1.draymode{auto,manual}如果为自动,则不能用MOUSE 点击TabButton.,否则可以
的。
2.ParentFont=true ,有便于统一界面。
3.TabSheet->TabWidth=0 则为有按钮,如为1,则看不到它。
4.tabview 可以确定那个PAGE 不让它使用。



十二.ListBox属性:

if(ListBox1->ItemIndex==-1) return ;

ListBox2->AddItem(ListBox1->Items->Strings[ListBox1->ItemIndex],NULL);
ListBox1->Items->Delete(ListBox1->ItemIndex);
//----------------
ListBox1->AddItem(ADOQuery1->FieldByName("office_name")->Value,NULL);
ADOQuery1->Next();
//-----------------
if (ListBox1->Count ==0) return ;
for(int i=0;i<ListBox1->Count;i++)
ListBox2->AddItem(ListBox1->Items->Strings[i],NULL);

ListBox1->Clear();

//-------------------
office_name="('" ;
{
for(int i=0;i<ListBox2->Count;i++)
office_name=office_name+ListBox2->Items->Strings[i]+"','";
}
office_name=office_name.SubString(1,StrLen(office_name.c_str())-2)+")";

//--------------------------------------
AnsiString caption=StringReplace(title->Text,"##",date1caption,
TReplaceFlags()<<rfReplaceAll) ;
caption=StringReplace(caption,"$$",date2caption,
TReplaceFlags()<<rfReplaceAll) ;



十三.怎样去掉CHILDFORM 中的关闭按钮。

EnabledCloseButton->Checked=!EnabledCloseButton->Checked;

if (EnabledCloseButton->Checked)
{
HWND m_hWnd=GetSystemMenu(Handle,false); //关闭按钮
EnableMenuItem(m_hWnd,SC_CLOSE,MF_DISABLED) ;
// EnableMenuItem(m_hWnd,SC_CLOSE,MF_GRAYED);
}
else
{
HWND m_hWnd=GetSystemMenu(Handle,false); //开启按钮
EnableMenuItem(m_hWnd,SC_CLOSE,MF_ENABLED) ;

}



--
如果你真的爱萤火虫,你就不应该将她困在瓶子里;
如果你真的爱萤火虫,你应该放开她,让她在天空中自由自在地飞!
虽然你会不舍得她,但是最终你就会明白这样你才真正拥有了她!

※ 来源:·荔园晨风BBS站 bbs.szu.edu.cn·[FROM: 210.21.224.234]


[回到开始] [上一篇][下一篇]

荔园在线首页 友情链接:深圳大学 深大招生 荔园晨风BBS S-Term软件 网络书店