Problems with IEnumerator: Enumerator is not started Exception

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dmi
    New Member
    • Sep 2007
    • 1

    Problems with IEnumerator: Enumerator is not started Exception

    Problems come when i added few table styles into DataGridTableSt yle Collection and then trying to get the current TableStyle.
    On first, ecxcuting this code
    Code:
                dgEmployees.DataSource = null; //DataGrid
                dgProjects.DataSource = null;
                dgEmployees.DataSource = DS;
                dgProjects.DataSource = DS;
                dgEmployees.TableStyles.Clear();
                int E_index = dgEmployees.TableStyles.Add(new DataGridTableStyle());
                dgEmployees.TableStyles[E_index].MappingName = "EmployeeTable";
                dgProjects.TableStyles.Clear();
                int P_index = dgProjects.TableStyles.Add(new DataGridTableStyle());
                dgProjects.TableStyles[P_index].MappingName = "ProjectTable";
    Then i trying to get the DataTable, on what current table style mapped to, in this code:
    Code:
                try
                        {
    
                            if (Table.TableStyles.Count > 0)
                            {
                                System.Collections.IEnumerator MuEnum = Table.TableStyles.GetEnumerator(); 
                                MappingName = ((DataGridTableStyle)MuEnum.Current).MappingName;
                            }
                            else
                                MappingName = "No table Styles";
    
                        }
                        catch(Exception err)
                        {
                            MappingName = "Unknown - errors at trying to use table styles.\n" + err.Message +
                                "\nStyles in table - " + dgEmployees.TableStyles.Count.ToString();
                        }
    How can I get current TableStyle?
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    You should've posted your question in the .NET forum section, not in the .NET
    articles section; I'll move your question over to the forum.

    kind regards,

    Jos

    Comment

    • Plater
      Recognized Expert Expert
      • Apr 2007
      • 7872

      #3
      Generally with Enumerators,
      You have to call the .Next() or something on them before using it because it starts on a blank spot "before" the first entry.

      I think.

      Comment

      Working...