locked
Not enough quota is available to process this command. (Exception from HRESULT: 0x80070718) in windows 8 metro app for GRID(Not for GRIDVIEW) RRS feed

  • Question

  • Hi,

    I am trying to generate dynamic controls in grid through UI  where am dynamically specifying the size of controls. while generating more then 1500 control it is throwing this error "Not enough quota is available to process this command. (Exception from HRESULT: 0x80070718) " . i have seen some solution for gridview for the same exception but i am using GRID so not beneficial for me . please give the solution . thanks in advance .

    Xaml code:

                

            <ScrollViewer HorizontalScrollMode="Auto" 
                  HorizontalScrollBarVisibility="Auto"
                  VerticalScrollMode="Auto"
                  VerticalScrollBarVisibility="Auto" Margin="232,10,267,0" Grid.Row="1">
                    <Grid Name="dynamicgrid" HorizontalAlignment="Stretch"  VerticalAlignment="Stretch" Background="LightBlue"   Height="Auto" Width="Auto" Grid.Row="1"/>

            </ScrollViewer>

    C# code 

     try
                {
                    MainPage mainpage = (MainPage)e.Parameter;
                    buttons = Convert.ToInt32(mainpage.buttonsize);
                    textblock = Convert.ToInt32(mainpage.txtBlocksize);
                    textbox = Convert.ToInt32(mainpage.txtBoxsize);
                    rows = Convert.ToInt32(mainpage.rows);
                    buttonwidth = Convert.ToInt32(mainpage.buttonwidth);
                    textblockwidth = Convert.ToInt32(mainpage.txtBlockwidth);
                    textboxwidth = Convert.ToInt32(mainpage.txtBoxwidth);
                    grdcolumn = buttons + textblock + textbox;


                    for (int i = 0; i < rows; i++)
                    {
                        RowDefinition rowDef = new RowDefinition();
                        rowDef.Height = new GridLength(200, GridUnitType.Auto);
                        dynamicgrid.RowDefinitions.Add(rowDef);

                    }
                    for (int j = 0; j < grdcolumn; j++) //need to mention
                    {
                        ColumnDefinition colDef1 = new ColumnDefinition();
                        colDef1.Width = new GridLength(100, GridUnitType.Auto);
                        dynamicgrid.ColumnDefinitions.Add(colDef1);
                    }

                    for (textboxcolumncount = 0; textboxcolumncount < textbox; textboxcolumncount++)
                    {
                        for (int i = 0; i < rows; i++)//textbox
                        {
                            TextBox txtbox = new TextBox();
                            txtbox.SetValue(TextBox.TextProperty, "txtbox" + i.ToString());
                            txtbox.Width = textboxwidth;
                            txtbox.Height = 50;
                            txtbox.SetValue(Grid.ColumnProperty, textboxcolumncount);
                            txtbox.SetValue(Grid.RowProperty, i);
                            dynamicgrid.Children.Add(txtbox);
                            dynamicgrid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });

                        }
                    }
                    textboxcolumncount = textbox;
                    for (textblockcolumncount = textboxcolumncount; textblockcolumncount < (grdcolumn - (buttons)); textblockcolumncount++)
                    {
                        for (int i = 0; i < rows; i++)
                        {
                            TextBlock txtblock = new TextBlock();
                            txtblock.SetValue(TextBlock.NameProperty, "txtblock" + i.ToString());
                            txtblock.Width = textblockwidth;
                            txtblock.Height = 50;
                            txtblock.SetValue(Grid.ColumnProperty, textblockcolumncount);
                            txtblock.SetValue(Grid.RowProperty, i);
                            txtblock.Text = "TextBlock" + i.ToString();
                            txtblock.Foreground = new SolidColorBrush(Colors.Black);
                            dynamicgrid.Children.Add(txtblock);
                            dynamicgrid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });

                        }
                    }
                    textboxcolumncount = textblockcolumncount;
                    for (buttonCoulmncount = textboxcolumncount; buttonCoulmncount < (grdcolumn); buttonCoulmncount++)
                    {
                        for (int i = 0; i < rows; i++) //button
                        {

                            Button btn = new Button();
                            btn.SetValue(Button.NameProperty, "btn" + i.ToString());
                            btn.Content = "Button" + i.ToString();
                            btn.Width = textboxwidth;
                            btn.Height = 50;
                            btn.Foreground = new SolidColorBrush(Colors.Black);
                            btn.SetValue(Grid.RowProperty, i);
                            btn.SetValue(Grid.ColumnProperty, buttonCoulmncount);
                            dynamicgrid.Children.Add(btn);
                            dynamicgrid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });

                        }
                    }

                }
                catch (Exception ex)
                {
                    throw ex;

                }
               

    .........................................................

    Friday, September 6, 2013 5:38 AM

Answers

  • Seems like a bad design.  Why do you need 1500 dynamic controls?

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Friday, September 6, 2013 1:04 PM
    Moderator
  • Hi,

    It's a bad idea to use ScrollView with 1500 controls because it doesn't has virtualization. Could you explain why do you need this.

    Saturday, September 7, 2013 12:25 AM

All replies

  • Seems like a bad design.  Why do you need 1500 dynamic controls?

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Friday, September 6, 2013 1:04 PM
    Moderator
  • Hi,

    It's a bad idea to use ScrollView with 1500 controls because it doesn't has virtualization. Could you explain why do you need this.

    Saturday, September 7, 2013 12:25 AM