On 23 Lut, 17:49, Otis Mukinfus <phoney.email.addr...@phoney.com>
wrote:
> On 23 Feb 2007 06:24:23 -0800, "Przemek M. Zawada" <przemek.zaw...@gmail.com>
> wrote:
>
>
>
> >Dear Group,
>
> >I'm developing sample window form, using DataGridView control, which
> >is filled with data through BindingSource, which is based on type of
> >object, as follow:
>
> >public sampleClass
> >{
> > public int itemNumber;
> > public string itemName;
> > public string itemCategory;
> > public bool itemActive;
>
> > public int ItemNumber
> > {
> > get { return itemNumber; }
> > set { itemNumber = value; }
> > }
> > public string ItemName
> > {
> > get { return itemName; }
> > set { itemName = value; }
> > }
> > public string ItemCategory
> > {
> > get { return itemCategory; }
> > set { itemCategory = value; }
> > }
> > public bool ItemActive
> > {
> > get { return itemActive; }
> > set { itemActive = value; }
> > }
> >}
>
> >So, everything seems to work perfect, the 'ItemActive'
> >DataGridViewCell is checkbox (as required), but the problem is when
> >I'd like to insert a ComboBox (DropDownList type) into a sample cell.
> >I have no idea how to do it through the object binding system - in the
> >matter of fact, is it even possible? Or the only way is through
> >creating step by step all DataGridView columns?
>
> >If any tutorial found, which might help me a bit, don't hesitate
> >writing it down.
>
> >Thank you very much for any help.
>
> >All the best,
> >Przemek M. Zawada
>
> You will need to create a BindingList<T> object containing the objects that
> contain at the very least an ID and description for the list you want to bind.
> You will then bind the combobox to the list with manually written code. You may
> be able to do the binding from the IDE by using a BindingSource object bound to
> the BindingList<T> object. I've not tried that.
>
> In addition to the above you might want to get the
> book "Data Binding with Windows Forms 2.0" by Bryan Noyes. It addresses data
> binding with objects extensively.
>
> Good luck with your project,
>
> Otis Mukinfus
>
> http://www.otismukinfus.comhttp://ww...//www.n5ge.com
Dear Otis,
I probably understood the idea you've explained above, but if it isn't
a big problem, could you paste here simplest example?
What I want to achieve is the following:
Object is defined as MyItemClass and with public fields: ItemID,
ItemName, ItemDescription, ItemCategory. ItemCategory (in
DataGridView) should be a string, which is displayed by (SelectedItem)
in ComboBox, which ones items are loaded from database.
Sample example of initiated object MyItemClass:
ItemID equals 1238
ItemName equals Lorem ipsum
ItemDescription equals Lorem ipsum dolor (...)
ItemCategory {
Category 1
Category 2 [selected]
Category 3
Category 4
}
I presume, that I need to define the type of object which describes
single item category - i.e. (int categoryId, string categoryName), and
then create in my (main) MyItemClass field as an array of for example
ItemCategoryObj[]. What next?
Sorry if that's rookie style of thinking, but I'm trying to upgrade my
knowledge in binding objects into windows forms.
Thank you for fast answer to my problem.
All the best,
Przemek M. Zawada