Custom dataGridColumn with two textboxes (or labels) one for each line of data to be displayed?

  • Thread starter Thread starter James Radke
  • Start date Start date
J

James Radke

Hello,

I am curious; how can I create my own custom datagridcolumn class that has
TWO controls in it (i.e. two textbox, label, etc). One for line one, and
one for line two (that way I can control the fonts/color of each line of
data within a column. Also, I would like BOTH controls to be databound,
where you can specify two different field names/expressions.

I have seen much on how to create a combo-box control, but nothing on how to
help me do what I need to do!

Does anyone have any suggestions / help they can offer?

Thanks!

Jim
 
Hi Jim,

Thanks for your post!

Before we start discussing this issue, I'd like to know If you are talking
about the DataGridColumnStyle class in WinForm, not the DataGridColumn
class in WebForm?

In this post, I assume you are talking about the WinForm DataGrid, if you
want to do such things in WebForm, you may repost this issue to our asp.net
related groups.

From your description, my understanding is you want to add two controls to
a datagrid column style, the cell being edited is divided into two lines,
one control for a line. And you also like to these two controls
databounded. If my understanding is not correct or incomplete, please let
me know.

Base on my knowledge, you may use several controls in a column style, a
better approach is put these controls into a user control and use the user
control in your column style class.
However this control will only show in the current editing cell,You may
override the Paint methods in the DataGridColumnStyle class to customize
draw the rest cells of this column.

As databinding support, It's hard to easily say it can or can not, the
answer is closely depended on what datasource you would like to bind and
what control does the data bound to. For example, if you bound your a
comboBox in your column style to the same datasource as the datagrid, when
you change the selection in the ComboBox it will change the current
position of the underlying CurrencyManager which will change the datagrid
current editing line accordingly, it's not a expected behavior when editing
value in a cell.

Maybe one workaround is to populate the value into these controls in Edit
method of ColumnStyle class and then update the corresponding values in
Commit method.

Are these suggestions helpful to you?
Please let me know if you have any further questions/problems/updates on
this issue,
Thanks!

Best regards,

Ying-Shen Yu [MSFT]
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
This mail should not be replied directly, "online" should be removed before
sending.
 
Back
Top