PC Review


Reply
Thread Tools Rate Thread

DataGridView customization question

 
 
Dick Swager
Guest
Posts: n/a
 
      23rd Sep 2008
I have a DataGridView with all DataGridViewTextBoxColumn columns. However I
want a DataGridViewCheckBoxCell in the one of the rows only. For example, I
want the cell in the 5th row, 3rd column to be a CheckBox (or maybe a
ComboBox) whereas all of the other cells in the DataGridView are TextBox
cells.

Is this possible? If so can someone point me to an example of how it is
done?

TIA, Dick

 
Reply With Quote
 
 
 
 
Suba
Guest
Posts: n/a
 
      2nd Oct 2008
Yes we can do that. I am not sure if my way of doing is the effecient way but
In the Databindcomplete event loop through the grid and based on specific
condition. In my case the column is a checkbox solumn and If specific
condition doesnot match i am masking the checkbox cell of a particular row
with textbox cell. So in my grid the rows where condition match is a checkbox
and rest of them are textbox.

I am doing this in
private void MainDatagridview_DataBindingComplete(object sender,
DataGridViewBindingCompleteEventArgs e)
{
for (int i = 0; i < this.MainDataGridView.Rows.Count; i++)
{
DataGridViewRow dr = this.MainDataGridView.Rows[i];
if (Global.User != null &&
dr.Cells["CommentCreatedById"].Value != null &&
!dr.Cells["CommentCreatedById"].Value.ToString().Equals(Global.User.UserID.ToString()))
{
DataGridViewTextBoxCell dc = new
DataGridViewTextBoxCell();
dc.Style.ForeColor = Color.FromArgb(240, 241, 246);
dc.Style.BackColor = Color.FromArgb(240, 241, 246);
dc.Style.SelectionBackColor = Color.FromArgb(240,
241, 246);
dc.Style.SelectionForeColor = Color.FromArgb(240,
241, 246);
dr.Cells["Active"] = dc;
dr.Cells["Active"].ReadOnly = true;
dr.Cells["Comments"].ReadOnly = true;
}
else
{
if (dr.Cells.Count > 1)
{
dr.Cells["Comments"].ReadOnly = false;
}
}
}
}

Hope this helps.

"Dick Swager" wrote:

> I have a DataGridView with all DataGridViewTextBoxColumn columns. However I
> want a DataGridViewCheckBoxCell in the one of the rows only. For example, I
> want the cell in the 5th row, 3rd column to be a CheckBox (or maybe a
> ComboBox) whereas all of the other cells in the DataGridView are TextBox
> cells.
>
> Is this possible? If so can someone point me to an example of how it is
> done?
>
> TIA, Dick
>

 
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
RibbonX Customization Question brplummer@gmail.com Microsoft Excel Programming 2 24th Jul 2008 04:48 PM
Template customization question =?Utf-8?B?SmFtZXM=?= Microsoft Access 0 5th Mar 2007 09:17 PM
Taskbar Customization Question =?Utf-8?B?RA==?= Windows XP Customization 1 31st May 2006 06:48 AM
Customization question =?Utf-8?B?dmVnd3JpdGVy?= Windows XP General 5 24th Apr 2005 03:29 AM
Sysprep customization question Melanie Windows XP Setup 0 14th Mar 2005 01:36 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:46 AM.