473,320 Members | 2,020 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

DataSource & DataMember property at custom control.

Hello!!!
I'm building a control that in a property
assign a Dataset which they are initialized and another property Like
DataMember.

Similar as it happens to the DataSource property of a System.Windows.Forms.ListBox...

That mechanism can be used or as is the best way to do it...
Thanks.
Alvaro.
Nov 17 '05 #1
3 10988
You can use a DataSource and DataMember. Underneath, this creates a
BindingManagerBase as so:

BindingManagerBase myBMB = BindingContext[dataSource, dataMember].

You can then access the data via the BindingManagerBase.

In most cases, you'll find the BindingManagerBase is actually a
CurrencyManager or RelatedCurrencyManager, depending on what exactly you're
binding to.

For more information about CurrencyManager I recommend this page:

http://noiseehc.freeweb.hu/CurrencyManager.html

I've also posted two article on my web site about it. I plan to do more,
just haven't gotten around to it yet:

http://www.petedavis.net/MySite/DynP...aspx?pageid=19
http://www.petedavis.net/MySite/DynP...aspx?pageid=22

Pete

The BindingContext actually returns a BindingManagerBase object but for a
datasource and
"Alvaro E. Gonzalez V." <ag********@gmail.com> wrote in message
news:O0**************@TK2MSFTNGP14.phx.gbl...
Hello!!!
I'm building a control that in a property
assign a Dataset which they are initialized and another property Like
DataMember.

Similar as it happens to the DataSource property of a
System.Windows.Forms.ListBox...

That mechanism can be used or as is the best way to do it...
Thanks.
Alvaro.

Nov 17 '05 #2
Hi,

I use this code:

private System.Windows.Forms.ListBox dropdownsource = new ListBox() ;
public object DataSource{
get {
return this.dropdownsource.DataSource;
}
set{
if (this.dropdownsource.DataSource != value)
this.dropdownsource.DataSource = value;
}
}

I hope that in the properties palete be shown the same way that DataSource ListBox's property

I must any attribute o Wath somethings i must do?

__________________________________________________ _______________________
Pete Davis wrote:
You can use a DataSource and DataMember. Underneath, this creates a
BindingManagerBase as so:

BindingManagerBase myBMB = BindingContext[dataSource, dataMember].

You can then access the data via the BindingManagerBase.

In most cases, you'll find the BindingManagerBase is actually a
CurrencyManager or RelatedCurrencyManager, depending on what exactly you're
binding to.

For more information about CurrencyManager I recommend this page:

http://noiseehc.freeweb.hu/CurrencyManager.html

I've also posted two article on my web site about it. I plan to do more,
just haven't gotten around to it yet:

http://www.petedavis.net/MySite/DynP...aspx?pageid=19
http://www.petedavis.net/MySite/DynP...aspx?pageid=22

Pete

The BindingContext actually returns a BindingManagerBase object but for a
datasource and
"Alvaro E. Gonzalez V." <ag********@gmail.com> wrote in message
news:O0**************@TK2MSFTNGP14.phx.gbl...
Hello!!!
I'm building a control that in a property
assign a Dataset which they are initialized and another property Like
DataMember.

Similar as it happens to the DataSource property of a
System.Windows.Forms.ListBox...

That mechanism can be used or as is the best way to do it...
Thanks.
Alvaro.


Nov 17 '05 #3
I found the solution :
private System.Windows.Forms.ListBox dropdownsource = new ListBox() ;

[RefreshProperties(RefreshProperties.Repaint)]
[TypeConverter("System.Windows.Forms.Design.DataSou rceConverter")]
public object DataSource{
get {
return this.dropdownsource.DataSource;
}
set{
if (this.dropdownsource.DataSource != value)
this.dropdownsource.DataSource = value;
}
}

[TypeConverter("System.Windows.Forms.Design.DataMem berFieldConverter")]
[Editor("System.Windows.Forms.Design.DataMemberFiel dEditor",typeof(System.Drawing.Design.UITypeEditor ))]
[DefaultValue("")]
public string DisplayMember{
get {
return this.dropdownsource.DisplayMember;
}
set{
if (this.dropdownsource.DisplayMember != value)
this.dropdownsource.DisplayMember = value;
}
}
[CLSCompliant(false)]
[TypeConverter("System.Windows.Forms.Design.ValueMe mberFieldConverter")]

[Editor("System.Windows.Forms.Design.DataMemberFiel dEditor",typeof(System.Drawing.Design.UITypeEditor ))]
[DefaultValue("")]
public string ValueMember{
get {
return this.dropdownsource.ValueMember;
}
set{
if (this.dropdownsource.ValueMember != value)
this.dropdownsource.ValueMember = value;
}
}
__________________________________________________ _________________________
Alvaro E. Gonzalez V. wrote:
Hi,

I use this code:

private System.Windows.Forms.ListBox dropdownsource = new ListBox() ;
public object DataSource{
get {
return this.dropdownsource.DataSource;
}
set{
if (this.dropdownsource.DataSource != value)
this.dropdownsource.DataSource = value;
}
}

I hope that in the properties palete be shown the same way that
DataSource ListBox's property

I must any attribute o Wath somethings i must do?

__________________________________________________ _______________________
Pete Davis wrote:
You can use a DataSource and DataMember. Underneath, this creates a
BindingManagerBase as so:

BindingManagerBase myBMB = BindingContext[dataSource, dataMember].

You can then access the data via the BindingManagerBase.

In most cases, you'll find the BindingManagerBase is actually a
CurrencyManager or RelatedCurrencyManager, depending on what exactly
you're binding to.

For more information about CurrencyManager I recommend this page:

http://noiseehc.freeweb.hu/CurrencyManager.html

I've also posted two article on my web site about it. I plan to do
more, just haven't gotten around to it yet:

http://www.petedavis.net/MySite/DynP...aspx?pageid=19
http://www.petedavis.net/MySite/DynP...aspx?pageid=22

Pete

The BindingContext actually returns a BindingManagerBase object but
for a datasource and
"Alvaro E. Gonzalez V." <ag********@gmail.com> wrote in message
news:O0**************@TK2MSFTNGP14.phx.gbl...
Hello!!!
I'm building a control that in a property
assign a Dataset which they are initialized and another property Like
DataMember.

Similar as it happens to the DataSource property of a
System.Windows.Forms.ListBox...

That mechanism can be used or as is the best way to do it...
Thanks.
Alvaro.


Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Dan | last post by:
i have a custom control. In the page load of the control I call a procedure called binddata which gets a dataset and binds to a gird. Then in my webform I create and instance of the control and...
3
by: anon | last post by:
I am having a hard time with makeing what I am trying to do work. I am making a questionaire web app. I have a custom control that has a label and 5 radio buttons. My problem is that each...
5
by: Steve R | last post by:
I am building a web custom control that encapsulates a series of dropdowns, buttons, etc. It is derived from a WebControl. I have the control built so that it renders properly. Now I am...
9
by: Jaybuffet | last post by:
my aspx has something like this <asp:Repeater id="Repeater1" runat="server"> <ItemTemplate> <mycontrol:ctl id="ctlId" obj='<%# Container.DataItem %>' showItem="true"/> </ItemTemplate>...
6
by: codoherty | last post by:
Is it possible to for a custom control to have 2 properties bound to 2 different fields from the same ADO.NET datasource. I noticed when writing updates to my datasource only 1 field or property...
14
by: Rolf Welskes | last post by:
Hello, I have an ObjectDataSource which has as business-object a simple array of strings. No problem. I have an own (custom) control to which I give the DataSourceId and in the custom-control...
1
by: rn5a | last post by:
I want to create a custom control that encapsulates a Button & a TextBox. When the Button is clicked, the user is asked a question using JavaScript confirm (which shows 2 buttons - 'OK' &...
1
Echooff3
by: Echooff3 | last post by:
I'm gonna pull my freakin hair out!!! This is the second time I had .Net lock me out of one of my forms with this error. I have a relational dataset and on a particular form there is the master...
0
by: mzwilli | last post by:
Hi, I'm trying to create browsable DataSource and DataMember properties on a user control. The idea is to create a descendent object, place a dataset then specify the DataSource (DataSet) and...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.