Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

How to remove the column in Data Grid View using C#

$
0
0

Hi all,

    Good Day! I am using C# in Microsoft Visual Studio 2008. In this I am viewing Remote Data Base tables  in  DataGridView Control. In this DataGridView Control i am viewing different Tables. Tables have different columns. so based on table columns i have to remove extra columns in Data Grid View. I tried it. but it is not working. Can you please give me an idea to solve it.

And my code is :

bool blank = true;
                            foreach (DataGridViewRow row in dataGridView1.Rows)
                            {
                                blank = true;

                                for (int i = 0; i <= row.Cells.Count - 1; i++)
                                {
                                    if (row.Cells(i).Value != null && !string.IsNullOrEmpty(row.Cells(i).Value))
                                    {
                                        blank = false;
                                        break;
                                    }
                                }
                                if (blank)
                                {
                                    if (!row.IsNewRow)
                                    {
                                        dataGridView1.Rows.Remove(row);

                                    }

                                }
                            }


Thanks & Regards Sasi ................. Go Green


Viewing all articles
Browse latest Browse all 2535

Trending Articles



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