|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How to create a "DataSource" & "Items" properties on Custom CombobI want to add 2 public properties "DataSource" and "Items" like the "System.Windows.Forms.ComboBox" here is my code, but it doesn't work. What's wrong with it? Public Property cboDataSource() As Object Get Return Me.cbo.DataSource 'cbo is my combobox End Get Set(ByVal Value As Object) Me.cbo.DataSource = Value End Set End Property Public Property cboItems() As System.Windows.Forms.ComboBox.ObjectCollection Get Return Me.cbo.Items End Get Set(ByVal Value As System.Windows.Forms.ComboBox.ObjectCollection) Me.cbo.Items.Add(Value) End Set End Property VB Newbie wrote:
Show quoteHide quote > I am creating a user control containing a combobox using VB.NET(2003) Why is the problem you are having with it?> I want to add 2 public properties "DataSource" and "Items" like the > "System.Windows.Forms.ComboBox" > > here is my code, but it doesn't work. What's wrong with it? > > Public Property cboDataSource() As Object > Get > Return Me.cbo.DataSource 'cbo is my combobox > End Get > Set(ByVal Value As Object) > Me.cbo.DataSource = Value > End Set > End Property > > Public Property cboItems() As System.Windows.Forms.ComboBox.ObjectCollection > Get > Return Me.cbo.Items > End Get > Set(ByVal Value As System.Windows.Forms.ComboBox.ObjectCollection) > Me.cbo.Items.Add(Value) > End Set > End Property > > -First problem I see is that you are mixing ideas here. You are trying to add an ObjectCollection to the collection. You should be additem the item. Let's say you were using strings (you could use object also, or datarow if your datasource is a datatable) Public Property cboItems(Index as integer) As String Get Return Me.cbo.Items(Index).toString End Get Set(ByVal Value As String) Me.cbo.Items.Add(Value) End Set End Property Hope it helps After applying your code, I can't view the "cboitem" property in VS.NET
designer view. How can I edit the "cboitem" and "cboDatasource" property in designer view like "System.Windows.Forms.ComboBox"'s one? Show quoteHide quote "Chris" wrote: > > Why is the problem you are having with it? > > -First problem I see is that you are mixing ideas here. You are trying > to add an ObjectCollection to the collection. You should be additem the > item. Let's say you were using strings (you could use object also, or > datarow if your datasource is a datatable) > > Public Property cboItems(Index as integer) As String > Get > Return Me.cbo.Items(Index).toString > End Get > Set(ByVal Value As String) > Me.cbo.Items.Add(Value) > End Set > End Property > > Hope it helps > VB Newbie,
Would it be not more advisable first to use the normal combobox in a bounded and not bounded way. From your sample and question, is it clear for me that you have not yet everything clear for yourself about the combobox. However feel free to go on this way. Cor How can I move on this way?
would you mind give me some hints? Show quoteHide quote "Cor Ligthert [MVP]" wrote: > VB Newbie, > > Would it be not more advisable first to use the normal combobox in a bounded > and not bounded way. From your sample and question, is it clear for me that > you have not yet everything clear for yourself about the combobox. > > However feel free to go on this way. > > Cor > > > VB Newbie,
> How can I move on this way? I have searched on MSDN, i found this page maybe is it something for you.> would you mind give me some hints? > http://msdn2.microsoft.com/en-us/library/k0e26a9k.aspx I hope this helps, Cor
When I get the image from the file the file remains locked
Problem with SHAppBarMessage Impersonation without credentials ? BUG? SqlDecimal = Single/Double: 4.475 becomes 4.4749999999999996D ???? Generate reports programmatically with reporting services & SQL server 2005 Encyrption in VB and Decryption in VB.NET DataTable.Expression Microsoft.VisualBasic.Compatibility New to XML Unwelcome forced pauses during code development in VS 2005 |
|||||||||||||||||||||||