Click here to Skip to main content
15,889,992 members
Articles / Programming Languages / C# 4.0
Tip/Trick

Delete Column in DataGridView

Rate me:
Please Sign up or sign in to vote.
1.33/5 (3 votes)
25 Nov 2015CPOL 8K   1   2
How to Delete Columns in a DataGridView

Introduction

This Article show you, how you can delete the Columns in a Datagridview 

Background

I had search long time to know how to clear the Columns in a DataGridView but i had not found some solution

Using the code

C++
DataTable newTable = new DataTable("TEST");
DataTable.ReadXML("TEST.xml");
dataTablefromYesterday.Rows.OfType<DataRow>().ToList().ForEach(r =>
    {
        r["Gesamtstunden"] = DBNull.Value;
        r["Anfangszeit"] = DBNull.Value;
        r["Endzeit"] = DBNull.Value;
    });

C#

History

Keep a running update of any changes or improvements you've made here.

License

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


Written By
Software Developer (Junior)
Germany Germany
This member doesn't quite have enough reputation to be able to display their biography and homepage.

Comments and Discussions

 
Question[My vote of 1] Misleading title Pin
Wombaticus25-Nov-15 11:00
Wombaticus25-Nov-15 11:00 
You haven't shown anything to do with a DataGridView, let alone deleting columns.
How did this "tip" get past the site moderators?

GeneralMy vote of 2 Pin
Manas_Kumar25-Nov-15 4:29
professionalManas_Kumar25-Nov-15 4:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.