Click here to Skip to main content
16,019,577 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Good day everyone please i have a datagridview where i store name,date and time, and i have a button that i don't want it to be visible if the row in the datagridview is greater than 1
but the button does not work properly

What I have tried:

if (exam.dataGridView1.Rows.OfType<DataGridViewRow>().Take(1).Count() > 1)
            {
                inexaminfo.Enabled = false;
            }

and also this
if (exam.dataGridView1.Rows.Count >1)
            {
                inexaminfo.Enabled = false;
              
            }
Posted
Updated 28-Sep-17 17:38pm
Comments
Graeme_Grant 28-Sep-17 23:31pm    
So when the DataGridView displays the rows, only row 1 will have a button?
akinwunmi 2-Oct-17 17:51pm    
now i want the button in another form to be enabled

1 solution

use Visible[^] property to show/hide the control

if (dataGridView1.Rows.Count > 1)
     inexaminfo.Visible = false;
 
Share this answer
 
Comments
akinwunmi 18-Oct-17 16:52pm    
I dont want my datagridview to be more than one.if it is more than one the button should be disabled
Karthik_Mahalingam 18-Oct-17 22:35pm    
for disabling you can use disabled property

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900