Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / July 2006

Tip: Looking for answers? Try searching our database.

How to change a DataColumn to ComboBox type column in a DataSet?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
nvx - 18 Jul 2006 19:32 GMT
Hi,
how can I change a DataColumn to ComboBox type column in a DataSet?
After I add a new column into the DataSet using

    MyDataSet.DataTable.Columns.Add("ColName");

I'd like to change its type so it would appear as a
DataGridViewComboBoxColumn in a DataGridView bound to this DataTable.

I also tried to create the ComboBox type column in the DataSet directly,
but failed (the Add method allows to create DataColumn columns only).

Or: could it be done by changing the column type in the DataGridView? If
so, how?

Thanks...

With regards
nvx
Dmytro Lapshyn [MVP] - 19 Jul 2006 08:43 GMT
Hi Nvx,

Your question doesn't have anything to do with DataSet. What you need
instead is to properly configure the ColumnStyles collection of the DataGrid
so a data column with a particular name is represented by the ComboBox
column style.

Signature

Regards,
Dmytro Lapshyn [MVP]
http://blogs.vbcity.com/DmytroL

> Hi,
> how can I change a DataColumn to ComboBox type column in a DataSet?
[quoted text clipped - 15 lines]
> With regards
> nvx
nvx - 19 Jul 2006 09:52 GMT
Thank you, Dmytro...

After posting the first question I looked at the DB in Access and found
out that there is not possible to set such a column type. Hence I
deleted the post you have replied to and posted another question (see
"How to change a DataGridViewTextBoxColumn to a
DataGridViewComboBoxColumn?") since I was not able to change it in the
DGV. Could you please give an exact line of code, which does this thing?

Thank you in advance.

With regards
nvx

Dmytro Lapshyn [MVP] napsal(a):
> Hi Nvx,
>
> Your question doesn't have anything to do with DataSet. What you need
> instead is to properly configure the ColumnStyles collection of the
> DataGrid so a data column with a particular name is represented by the
> ComboBox column style.
nvx - 19 Jul 2006 09:58 GMT
Oh, I'm sorry, I forgot to add I'm coding in C#...

nvx

nvx napsal(a):
> Thank you, Dmytro...
>
[quoted text clipped - 17 lines]
>> DataGrid so a data column with a particular name is represented by the
>> ComboBox column style.
edgarrolla@yahoo.com.br - 25 Jul 2006 15:43 GMT
Is it possible to be done in run time?
Is it actually possible to change a single cell style programmacticaly?

cheers!

> Oh, I'm sorry, I forgot to add I'm coding in C#...
>
> nvx
>
> nvx napsal(a):
Paul Jones - 25 Jul 2006 16:45 GMT
Well, it can be done with

    DataGridViewCell cell = new DataGridViewComboBoxCell();
    DGV.Columns["colname"].CellTemplate = cell;

There's a catch though: the new column type must be derived from the
actual type or something like that, I do not remember it exactly... If
it is possible, try to create columns of needed type and you're saved
from changing theirs type in the future. I know this solution can't be
applied to every case, but to most of them it can, I guess...

P.J.

edgarrolla@yahoo.com.br napsal(a):
> Is it possible to be done in run time?
> Is it actually possible to change a single cell style programmacticaly?
[quoted text clipped - 6 lines]
>>
>> nvx napsal(a):

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.