Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

select all buttons on form

$
0
0

Hi

I have below code :

foreach (Control  c in frmM.tableLayoutPanel1.Controls ) 
            {
                foreach (DataRow row in table.Rows)
                {
                    foreach (var item in row.ItemArray)
                    {
                        var button = c  as Button;
                        if ((button.Name.ToString() == item.ToString()))
                        {
                            button.Enabled = false;
                        }
                    }
                }

            }

the condiyion of IF work but unfortunately the below line don't work:

button.Enabled = false;

and also I want use

foreach (Control  c in frmM.Controls )

but because my form don't have button directely so this code isn't useful for me.

Is there any better code that I could use?


Viewing all articles
Browse latest Browse all 31927

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>