Link to home
Start Free TrialLog in
Avatar of Mickeys
MickeysFlag for Sweden

asked on

Add a new column to my GridView

How do I add an extra column to my gridview?

I have the code below.

This is what it looks like right now
Name    Phone     Adress

And I want to add one more column lilke this
Name    Phone     Adress     E-mail

How?
/// <summary>
        /// Updater updates the gui
        /// </summary>
        private void Updater()
        {
            //Update the gridview
            AnimalDataGridView.DataSource = null;
            AnimalDataGridView.AutoGenerateColumns = true;
            AnimalDataGridView.DataSource = animalManager.AnimalList;
            nickNameTextBox.Text = "";
            nrOfItems.Text = Convert.ToString(animalManager.Counter);
        
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Rahul Goel
Rahul Goel
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mickeys

ASKER

I am not using ASP so I cant use BoundColumn I guess.

I am not using a sql data bas. My DataGridView is using a List<Contacts>
Then you need to create a new property in class Contact called EmailAddress or your other columns.

Or

You need to mannually add columns in gridview of windows app and then bind to the specific property of the contact class.
Avatar of Mickeys

ASKER

well I have managed to put it into the gridview manually but......how do I choose where it should be? Right now it is the first cell. I want it to be the last