views:

64

answers:

1

Hi all!

I'm working on a C# application and need to give the users a user-friendly environment to work in. The idea is that a user uses his/her id and password so only data relevant to the user will show up in a table. I've figured out how to do this but now the user needs to be able to edit the contents of the table and since it's all about giving the user that friendly looking interface.

What table-like component should I use to achieve this? I need to be able to load in data and save the edited data back into the database but I also need to be able to assign colours to individual cells and borders to make it look more user-friendly. Also I prefer a click-and-edit way of editing the table contents.

I already tried using the DataGridView but it fell short on customizing it's appearance.

Is there another good .net component I can make use of to achieve this?


EDIT: It's a windows Forms desktop application.

+1  A: 

Use the CellFormatting event to change individual cells when binding them to the datagrid

example from my own code:

private void dgColorCodeKey_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{  
    if (e.RowIndex >= 0)
    {
        //if we are binding a cell in the Color column
        if (e.ColumnIndex == colColor.Index)
        {
         //ColorCode is a custom object that contains the name of a System.Drawing.Color
     ColorCode bindingObject = (ColorCode)dgColorCodeKey.Rows[e.RowIndex].DataBoundItem;
     dgColorCodeKey[e.ColumnIndex, e.RowIndex].Style.BackColor = Color.FromName(bindingObject.Color);

     //set this property to true to tell the datagrid that we've applied our own formatting
     e.FormattingApplied = true;
        }
    }
}

Additionally, see this Data Grid FAQ for a really good, clear description of how a datagrid works and what various methods and events do.

Zack
Thank you very much
Pieter888