Yanshof
Yanshof

Reputation: 9926

How to set Grid Raw number & Grid Column number dynamically?

I want to set Grid Raw number & Grid Column number dynamically according to a parameter that I will get.

How can I do it ?

Upvotes: 0

Views: 328

Answers (2)

Sonosar
Sonosar

Reputation: 526

Use this:

 private void SetGridRowColumnNumber(Grid grid, int rowCount, int columnCount)
        {
            grid.RowDefinitions.Clear();
            grid.ColumnDefinitions.Clear();
            for (int i = 0; i < rowCount; i++)
            {
                grid.RowDefinitions.Add(new RowDefinition());
            }

            for (int i = 0; i < columnCount; i++)
            {
                grid.ColumnDefinitions.Add(new ColumnDefinition());
            }
        }

please let me know if this didn't help.

Upvotes: 1

sandeeZ
sandeeZ

Reputation: 61

datagridview1.Item(column index, Row index)

Upvotes: 0

Related Questions