views:

32

answers:

1

Hello guys,

I'm using this tutorial from MSDN (to the letter) and I'm failing to add new rows to my datagridview component.

http://msdn.microsoft.com/library/7tas5c80%28en-us,vs.80%29.aspx

When I try to add a new row, there is an error: "At least one of the cells do not have a cell style defined". According to the code, the CellStyle is defined on InitializeEditingControl in the class CalendarCell.

But looking at the code, nowhere that cellStyle is actually defined. Could this be it? I could not find where the error is.

I'm using two methods to build my columns (after the form initializes):

public static CalendarColumn BuildCalendarColumn(string columnName, string toolTip, string headerText, int width)
{
    CalendarColumn column = new CalendarColumn();
    column.Name = columnName;
    column.HeaderText = headerText;
    column.ToolTipText = toolTip;

    return column;
}

    private void BuildMemorialPointDataGridColumns(DataGridView dataGridView)
    {
        DataGridViewColumn column1 = DataGridViewColumnBuilder.BuildStandartColumn
            (
                MemorialPointUiDetails.MemorialPointNameColumnName,
                MemorialPointUiDetails.MemorialPointNameColumnHeader,
                MemorialPointUiDetails.MemorialPointNameColumnHeader,
                50
            );
        dataGridView.Columns.Add(column1);

        DataGridViewComboBoxColumn column2 = DataGridViewColumnBuilder.BuildComboBoxColumn
            (
                MemorialPointUiDetails.MemorialPointTypeColumnName,
                MemorialPointUiDetails.MemorialPointTypeColumnHeader,
                MemorialPointUiDetails.MemorialPointTypeColumnHeader,
                50,
                typeof(MemorialPointType)
            );
        dataGridView.Columns.Add(column2 as DataGridViewColumn);

        DataGridViewColumn column3 = DataGridViewColumnBuilder.BuildStandartColumn
            (
                MemorialPointUiDetails.MemorialPointXColumnName,
                MemorialPointUiDetails.MemorialPointXColumnHeader,
                MemorialPointUiDetails.MemorialPointXColumnHeader,
                50
            );
        dataGridView.Columns.Add(column3);

        DataGridViewColumn column4 = DataGridViewColumnBuilder.BuildStandartColumn
            (
                MemorialPointUiDetails.MemorialPointYColumnName,
                MemorialPointUiDetails.MemorialPointYColumnHeader,
                MemorialPointUiDetails.MemorialPointYColumnHeader,
                50
            );
        dataGridView.Columns.Add(column4);

        DataGridViewColumn column5 = DataGridViewColumnBuilder.BuildCalendarColumn
            (
                MemorialPointUiDetails.MemorialPointStartTimeColumnName,
                MemorialPointUiDetails.MemorialPointStartTimeColumnHeader,
                MemorialPointUiDetails.MemorialPointStartTimeColumnHeader,
                50
            );
        dataGridView.Columns.Add(column5);

        DataGridViewColumn column6 = DataGridViewColumnBuilder.BuildCalendarColumn
            (
                MemorialPointUiDetails.MemorialPointFinishTimeColumnName,
                MemorialPointUiDetails.MemorialPointFinishTimeColumnHeader,
                MemorialPointUiDetails.MemorialPointFinishTimeColumnHeader,
                50
            );
        dataGridView.Columns.Add(column6);

        DataGridViewColumn column7 = DataGridViewColumnBuilder.BuildStandartColumn
            (
                MemorialPointUiDetails.MemorialPointTotalTimeColumnName,
                MemorialPointUiDetails.MemorialPointTotalTimeColumnHeader,
                MemorialPointUiDetails.MemorialPointTotalTimeColumnHeader,
                50
            );
        dataGridView.Columns.Add(column7);

    }

I'm not sure if I'm being clear, but am I doing something wrong? I mean, does dataGridViewColumns need to created in a different manner that I'm not aware?

Thanks

A: 

What is DataGridViewColumnBuilder in your code?

Mamta Dalal
it builds columns for me :P
George