扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
Label *label; TextBox *textbox; Button *button; |
SearchControl::SearchControl() { label = new Label(); textbox = new TextBox(); button = new Button(); } |
void SearchControl::CreateChildControls() { Controls->Add(label); Controls->Add(textbox); Controls->Add(button); } |
void SearchControl::Render(HtmlTextWriter *output) { __super::Render(output); } |
[Bindable(true), Category("Appearance"), DefaultValue("")] __property void set_Value(String *value); __property String *get_Value(); [Bindable(true), Category("Appearance"), DefaultValue("")] __property void set_LabelText(String *value); __property String *get_LabelText(); [Bindable(true), Category("Appearance"), DefaultValue("")] __property void set_ButtonText(String *value); __property String *get_ButtonText(); |
String *SearchControl::get_LabelText() { this->EnsureChildControls(); return label->Text; } void SearchControl::set_LabelText(String *value) { this->EnsureChildControls(); label->Text = value; } String *SearchControl::get_Value() { this->EnsureChildControls(); return textbox->Text; } void SearchControl::set_Value(String *value) { this->EnsureChildControls(); textbox->Text = value; } String *SearchControl::get_ButtonText() { this->EnsureChildControls(); return button->Text; } void SearchControl::set_ButtonText(String *value) { this->EnsureChildControls(); button->Text = value; } |
void SearchControl::CreateChildControls() { System::Web::UI::WebControls::Table *table = new Table(); TableRow *row = new TableRow(); TableCell *cell1 = new TableCell(); TableCell *cell2 = new TableCell(); TableCell *cell3 = new TableCell(); cell1->Controls->Add(label); cell2->Controls->Add(textbox); cell3->Controls->Add(button); row->Cells->Add(cell1); row->Cells->Add(cell2); row->Cells->Add(cell3); table->Rows->Add(row); Controls->Add(table); } |
[Bindable(true), Category("Appearance")] __property void set_LabelWidth(Unit value); __property Unit get_LabelWidth(); [Bindable(true), Category("Appearance")] __property void set_LabelAlign(HorizontalAlign value); __property HorizontalAlign get_LabelAlign(); |
Unit SearchControl::get_LabelWidth() { this->EnsureChildControls(); return cellLabel->Width; } void SearchControl::set_LabelWidth(Unit value) { this->EnsureChildControls(); cellLabel->Width = value; } HorizontalAlign SearchControl::get_LabelAlign() { this->EnsureChildControls(); return cellLabel->HorizontalAlign; } void SearchControl::set_LabelAlign(HorizontalAlign value) { this->EnsureChildControls(); cellLabel->HorizontalAlign = value; } |
void SearchControl::CreateChildControls() { System::Web::UI::WebControls::Table *table = new Table(); TableRow *row = new TableRow(); TableCell *cell2 = new TableCell(); TableCell *cell3 = new TableCell(); cellLabel->Controls->Add(label); textbox->Width = Unit::Percentage(100); cell2->Controls->Add(textbox); cell3->Controls->Add(button); row->Cells->Add(cellLabel); row->Cells->Add(cell2); cell3->Width = Unit::Percentage(1); row->Cells->Add(cell3); table->Rows->Add(row); table->Width = Unit::Percentage(100); Controls->Add(table); } |
button->Click += new EventHandler(this, buttonClicked); |
void SearchControl::buttonClicked(Object *sender, EventArgs *e) { OnClick(e); } |
__event EventHandler* Click; |
void SearchControl::OnClick(EventArgs *e) { if (Click != 0) Click(this, e); } |
[DefaultProperty("Value"), DefaultEvent("Click"), ToolboxData("<{0}:SearchControl runat=server></{0}:SearchControl>")] public __gc class SearchControl : public System::Web::UI::WebControls::WebControl {} |
private void SearchControl1_Click(object sender, System.EventArgs e) { WebCustomControl1.Text = SearchControl1.Value; } |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者