Windows Develop Bookmark and Share   
 index > Windows Forms General > Role through a datagridview - set readonly as datagridview gets populated
 

Role through a datagridview - set readonly as datagridview gets populated

Hi,

I want to display certain rows readonly & change back color of a datagridview & displayed as the grid gets populated

The problem i have is that I'm using the RowEnter Event - which works when the user selects a row

But i whant it to be displayed on the grid visually without selecting a row - when grid gets populated:

private void dgvDetail_RowEnter(object sender, DataGridViewCellEventArgs e)

{dgvCurrentRow = dgvDetail.Rows[e.RowIndex];

if (oLOTXLOCXID_Row["WhsLPNo"].ToString() == "Found")

{dgvCurrentRow.DefaultCellStyle.BackColor = this.BackColor;

dgvCurrentRow.DefaultCellStyle.ForeColor = SystemColors.GrayText;

dgvCurrentRow.ReadOnly = true;

dgvCurrentRow.Cells[10].Value = 1;}}

I tried RowsAdded Event - but that does not even rollthrough the entire grid only entered it twice - so only the second row was disabled.

Please Help!

  • Moved byHarry ZhuMSFTFriday, October 02, 2009 6:36 AMrelating to datagridview control (From:Visual C# General)
  • Changed TypeAland LiMSFT, ModeratorThursday, October 08, 2009 4:56 AMNo reply
  •  
Ismailc  Thursday, October 01, 2009 7:42 AM
Hi Ismailc,

Based on my understanding, you can traverse all the rows after the grid is populated and run the code you provided to disable the rows. Could you let me know why you handled the Enter or RowsAdded events?

Regards,
Aland Li
Please mark the replies as answers if they help and unmark if they don't. This can be beneficial to other community members reading the thread.
Aland Li  Monday, October 05, 2009 10:25 AM

Hi,

We are changing the issue type to “General Discussion” because you have not followed up with the necessary information. If you have more time to look at the issue and provide more information, please feel free to change the issue type back to “Question” by opening the Options list at the top of the post window, and changing the type. If the issue is resolved, we will appreciate it if you can share the solution so that the answer can be found and used by other community members having similar questions.

Aland Li


Please mark the replies as answers if they help and unmark if they don't. This can be beneficial to other community members reading the thread.
Aland Li  Thursday, October 08, 2009 4:56 AM

You can use google to search for other answers

Custom Search

More Threads

• C# how to detect whether a computer got sound device or not by code
• Help on Line Charts / Pie charts in C#
• Panel control problem discovered...
• Populate listbox in window1 from window2
• I can't reach my program with using keyboard.
• Tablet pc ink in DataGridView
• Modal Dialog in Thread
• Network authentication and windows services
• LINQ to SQL and DataGridView Databinding woes
• app.config