I've been trying to create a custom collection that can be bound to a
combobox via the DataSource property, but I can't seem to get it to work.
I've created a class that implements IList, and it seems to work okay on its
own, but when I try to bind it to a combobox, the combobox doesn't show
anything (and it starts having problems repainting itself). The Datasource
appears to contain my custom collection object, but when I ask for its item
count I receive zero when I should be receiving a higher number.
Has anyone tried to do something like this before and succeeded? Maybe
there's just a problem with my implementation of IList? I can post my code
(it's long) or email it if anyone wants to see it.
- Don 2 1419
Just base your collection on CollectionBase and fill in the appropriate
blanks of Add, Remove and indexer.
--
Bob Powell [MVP]
Visual C#, System.Drawing
Answer those GDI+ questions with the GDI+ FAQ http://www.bobpowell.net/gdiplus_faq.htm
The GDI+ FAQ RSS feed: http://www.bobpowell.net/faqfeed.xml
Windows Forms Tips and Tricks RSS: http://www.bobpowell.net/tipstricks.xml
Bob's Blog: http://bobpowelldotnet.blogspot.com/atom.xml
"Don" <un*****@oblivi on.com> wrote in message
news:waNid.1296 21$nl.78350@pd7 tw3no... I've been trying to create a custom collection that can be bound to a combobox via the DataSource property, but I can't seem to get it to work. I've created a class that implements IList, and it seems to work okay on
its own, but when I try to bind it to a combobox, the combobox doesn't show anything (and it starts having problems repainting itself). The
Datasource appears to contain my custom collection object, but when I ask for its
item count I receive zero when I should be receiving a higher number.
Has anyone tried to do something like this before and succeeded? Maybe there's just a problem with my implementation of IList? I can post my
code (it's long) or email it if anyone wants to see it.
- Don
Okay, I followed the instructions for creating a class based on
CollectionBase. It now binds to a combobox, but the combobox just shows the
class name instead of the value the ToString property returns for each
object. What's up with that?
- Don
"Bob Powell [MVP]" <bob@_spamkille r_bobpowell.net > wrote in message
news:eP******** ******@TK2MSFTN GP12.phx.gbl... Just base your collection on CollectionBase and fill in the appropriate blanks of Add, Remove and indexer.
-- Bob Powell [MVP] Visual C#, System.Drawing
Answer those GDI+ questions with the GDI+ FAQ http://www.bobpowell.net/gdiplus_faq.htm
The GDI+ FAQ RSS feed: http://www.bobpowell.net/faqfeed.xml Windows Forms Tips and Tricks RSS: http://www.bobpowell.net/tipstricks.xml Bob's Blog: http://bobpowelldotnet.blogspot.com/atom.xml "Don" <un*****@oblivi on.com> wrote in message news:waNid.1296 21$nl.78350@pd7 tw3no... I've been trying to create a custom collection that can be bound to a combobox via the DataSource property, but I can't seem to get it to
work. I've created a class that implements IList, and it seems to work okay on its own, but when I try to bind it to a combobox, the combobox doesn't show anything (and it starts having problems repainting itself). The Datasource appears to contain my custom collection object, but when I ask for its item count I receive zero when I should be receiving a higher number.
Has anyone tried to do something like this before and succeeded? Maybe there's just a problem with my implementation of IList? I can post my code (it's long) or email it if anyone wants to see it.
- Don
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Martin Schulze |
last post by:
Hello,
i tried to compose myself a custom usercontrol which is derieved from
System.Windows.Forms.UserControl.
It contains 2 comboboxes and one textbox (which are also custom
controls,
but directly derived from the .net classes ComboBox and TextBox)
I did the custom control in the visual studio .net designer in which i
|
by: ASP Yaboh |
last post by:
I have an ArrayList of data gathered from a database. I want to create a web
page from this data by creating a <table>, each cell in each row displays the
appropriate data. One of those cells in each row needs a <textarea> control.
The background supporting classes are completed, the only task left now is
to create the web page. I am at a loss on how to create the table in the page
populated by the data. Previously, I would have just...
|
by: Adjo |
last post by:
Okay, I've seen all the examples of using comboboxes on webforms when
using simple values. And in the issue-tracker starterkit there is a way
to use comboboxes with id/value foreign keys in a smart (but hard!)
way.
I think every developer needs bound comboboxes to store foreign
keyvalues while displaying the user-friendly value as it is stored in
the foreign table, so there must be plenty of you that have found a way
to do so...
In a...
|
by: Adam J. Schaff |
last post by:
Hello. I have a custom collection that implements IBindingList (allownew and
allowremove are both true). I have bound it to a datagrid. I have add and
remove buttons on the screen. I want to implement those buttons, but I'm not
sure what the code should look like.
I tried what I thought was obvious code:
myCollection.AddNew()
and
|
by: Frnak McKenney |
last post by:
Can I use a bound ComboBox for both browsing and editing?
I'm working on a small, standalone database application using Visual
C#.NET 2003 and an Access data file.
In order to keep the number of different screens down to a minimum,
I'm trying to use the same Windows Forms for both browsing and for
updating. This works fine for TextBoxes, but I'm running into
problems with my DropDownLists (ComboBoxes).
| |
by: Big Charles |
last post by:
Hello,
I would like to create an array-class to be able to call like:
Dim oMyCar as New MyCar
' After initializing oMyCar, the object has to be like:
oMyCar(0).Brand
oMyCar(0).Wheels.NumberOfWheels
oMyCar(0).Wheels.ColorOfWheels
|
by: Randy |
last post by:
I have a routine that creates a series of comboboxes, each of which is
bound to a common dataview. Everything used to work fine, but now,
when I change the value of any of the comboboxes, the value in ALL of
the comboboxes changes to the new value. I have boiled down the code
to the simplest lines and placed it on its own form, but I still get
the same behavior. I have stepped through each line of code, and I
don't see any other lines...
|
by: Wingot |
last post by:
Hey,
I have a view to a database that I have created for Client Maintenance. It has
a number of fields, but the important ones are Medical Condition, Bill To, and
Country.
I have a couple of external tables: One for Countries that store each Country
as a ID (char(2)), and Name (varchar(50)) pair; One for Medical Conditions,
using ID (int) and Name (varchar(50)). Also, the BillTo field refers back to
the same table that is being...
|
by: Ben |
last post by:
Does anyone have any example code showing how to sort a datagrid that
is bound to a custom class array? My code calls a web method that
returns an array of type LeadListDS. LeadListDS consists of string,
DateTime, and boolean datatypes. This returned array is then bound to
the datagrid and seems to work fine I just need to figure out this
sorting issue. Thanks
Ben
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |