PC Review


Reply
Thread Tools Rate Thread

Combo / List in Datagrid

 
 
Maria
Guest
Posts: n/a
 
      10th Dec 2003
When adding records through a datagrid I would like one
of the fields only to accept the values 'Yes' or 'No' is
it possible to set this field to some kind of combobox or
list. The datatype for the field in the database is set
to Yes/No and I thought that this may have been directly
translated after binding had taken place but this was not
the case (

what I ultimately want to do is place a filter on the
records shown in the datagrid based on the result of this
field

I normally develop apps of this nature in Access and have
lost my way here a bit how can I achieve this effect

Maria
 
Reply With Quote
 
 
 
 
One Handed Man [ OHM# ]
Guest
Posts: n/a
 
      10th Dec 2003
Maria,
This is tricky but it is do-able. Basically you need to add a
combo box to your form and make it invisible. To add over the current cell
do the following, I dont have full code for you but this should help.


Rectangle rect;

rect = dataGrid1.GetCurrentCellBounds();

comboBox1.Width = rect.Width;

comboBox1.Height = rect.Height;

comboBox1.Left = rect.Left + dataGrid1.Left;

comboBox1.Top = rect.Top + dataGrid1.Top;

comboBox1.Visible = true;

What you then need to do is to update the current cell when the values are
changed in the comboBox. This also needs to be tied into the paint even for
the form because you need to detect which column needs the combo box. And
when shifting from one that does to one that doesent you need to make sure
you repaint to get updated values etc.

Regards - OHM








Maria wrote:
> When adding records through a datagrid I would like one
> of the fields only to accept the values 'Yes' or 'No' is
> it possible to set this field to some kind of combobox or
> list. The datatype for the field in the database is set
> to Yes/No and I thought that this may have been directly
> translated after binding had taken place but this was not
> the case (
>
> what I ultimately want to do is place a filter on the
> records shown in the datagrid based on the result of this
> field
>
> I normally develop apps of this nature in Access and have
> lost my way here a bit how can I achieve this effect
>
> Maria


Regards - OHM# (E-Mail Removed)


 
Reply With Quote
 
Maria
Guest
Posts: n/a
 
      10th Dec 2003
Oh dear ( lol

How about a checkbox does that generate the same sort of
problems ?

regards Maria
 
Reply With Quote
 
One Handed Man [ OHM# ]
Guest
Posts: n/a
 
      10th Dec 2003
Yes.
OHM#

Maria wrote:
> Oh dear ( lol
>
> How about a checkbox does that generate the same sort of
> problems ?
>
> regards Maria


Regards - OHM# (E-Mail Removed)


 
Reply With Quote
 
Jeremy Cowles
Guest
Posts: n/a
 
      10th Dec 2003
This is not an ADO.NET or WinForms group, I would try a group that is in the
context of your quetion (you will get a better response).

I agree with Maria, just use a Check box if there are only two values.

BTW: Microsoft has an article on their site on how to do exactly what you
want, sorry I dont have the exact link: http://msdn.microsoft.com/

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
limit the contents of one combo/list box based on what's selected inanother combo/list box CDF Microsoft Access 11 7th Mar 2009 03:23 PM
datagrid combo box selection not showing in datagrid JL3574 l Microsoft C# .NET 0 19th Oct 2005 05:47 PM
How to add a Dropdown list to a datagrid at runtime (dynamic) without using template columns in ASP.NET and still have the ability to us the datagrid Update event. Daniel Roth Microsoft Dot NET Framework 0 5th Apr 2005 04:54 AM
filtering or limiting combo/list box from another combo/list box =?Utf-8?B?am1r?= Microsoft Access Form Coding 20 26th Jan 2005 10:07 PM
Combo/List Box - Trigger secondary List/Combo Box? =?Utf-8?B?RG9yZWVu?= Microsoft Access Form Coding 3 14th Oct 2004 08:05 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:54 PM.