473,396 Members | 1,847 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to put different cell type in the same DataGrid column?

I want put into my DataGrid different control types in the same column.
For example:
Column 1, row 0 ==> TextBox
Column 1, row 2 ==> CheckBox
Column 1, row 2 ==> ComboBox
etc...

As I see, I can hold only one kind of sell type in the same column. is there
a way to do it anyway.

At http://www.codeproject.com/cs/miscct...edControls.asp it's
been done for ListView.
-------
Thanks
Sharon
Jun 20 '06 #1
2 7409
Hi Sharon,

Thanks for your post!

In non-editing mode, DataGrid does not display the real controls, the
DataGridColumnStyle paints the cell contents internally. So when you are
using DataGridBoolColumn, the checkboxes in that column are not the real
checkboxes, DataGridBoolColumn.Paint method draws the dummy CheckBoxes. You
may use Reflector to view DataGridBoolColumn.Paint method source code to
verify this.

Whenever the end user clicked certain cell in DataGrid, the DataGrid will
invoke corresponding DataGridColumnStyle's Edit method. Normally, this
method will show an internal Control and move to that cell rectangle. In
non-editing mode, that editing control is in invisible state. Please refer
to DataGridTextBoxColumn.Edit method with Reflector to see the code.

With these background information, you can see that DataGridColumnStyle
will host an invisible control in initialization time, while shows it out
in editing time. Conceptually, what you want can be achieved with
customized code. You may inherit from DataGridColumnStyle and create
several controls in the constructor, then in Edit method, you may show out
you wanted control regarding the editing row number. Also, you have to
decide what control appearance to draw in the Paint method. There are still
some that issues to consider, for example, commit the control editing value
to the datasource etc... This is a not easy work to be done.

Currently, I can not find any sample regarding your requirement. If you
want to implement it, you may refer to the 2 articles below for a sample.
These 2 articles both demonstrates hosting one control in the column, you
may extend with customized code following the logic I decribed above:
"Columns With Style"
http://www.i-syn.gmxhome.de/devcom/colstyles/intro.htm
"5.9 How can I put a combobox in a column of a datagrid?"
http://64.78.52.104/FAQ/WinForms/FAQ_c44c.asp#q480q

Hope this helps!

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 21 '06 #2
Hi Sharon,

Does my reply make sense to you? If you have any concern, please feel free
to tell me, thanks!

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 23 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Tim Nelson | last post by:
I am missing something obvious here. I have a simple grid with 2 columns pulled from an ADO.NET ODBC datasource. All that I want to do is lengthen the columns in the grid so each field displays...
2
by: Stephen | last post by:
Is it possible to add a tooltip in the column of a Datagrid. Can someone please show me how I would do this for the datagrid column below. Thanks for any help anyone can give me. Here is the...
1
by: Hans | last post by:
I have a Windows.Forms.Form containing a DataGrid where the DataSource is a DataView. Everything refreshes fine after adding, deleting or editing rows. When I close the dialog and reopen it with a...
9
by: Paul | last post by:
Hi I have a data grid with a hyperlink column. the colum has numbers like 00001,000002, ect. Just wondering how to get the text value of the cell as tempstring =...
16
by: tshad | last post by:
I am trying to center a button in a datagrid column in asp.net and it doesn't seem to work. I have the following: <asp:TemplateColumn ItemStyle-Width="10%" ItemStyle-HorizontalAlign="Center">...
2
by: gane | last post by:
Any ideas on how to assign value to a datagrid cell referencing the column name? I would like to assign a value to a datagrid item using the column name (from web.config file) instead of using...
1
by: John | last post by:
Can anyone give me hints on how to do this? I need to have a single column in a dataviewgrid whose cells can be set to either a combo box, a text edit or a check box, different for each row of the...
0
by: Mark | last post by:
I need to format the cells of one Column of DataGrid, on the Pocket PC with Windows CE vers. 4.2 The problem is that in the libreries of C# for Windows CE, there isn't the paint method of...
2
by: phpfreak2007 | last post by:
Hello all, I am Using One grid with Three column and I want to add Different Cell type in Same Column.. I can display properly with the error. code is as below.. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
jinu1996
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.