This is a migrated thread and some comments may be shown as answers.

Getting Columns that contains a certain string

1 Answer 73 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Empanada
Top achievements
Rank 1
Empanada asked on 11 Jan 2012, 02:10 PM

Hey :)

I made a radgridview  that displays too multiple columns

And within this radgridview  , it has a column FirstNAme, MiddleName, LastName,  QuizAverage, Quiz1, Quiz2, Quiz3 etc

How can I get the columns that contains the string "Quiz" such as QuizAverage, Quiz1, Quiz2, Quiz3 etc.. without specifying their indexes?
Just by mere Identifying wheter a ceratin column name contains "Quiz"

Thanks for help in this regard :)

1 Answer, 1 is accepted

Sort by
0
Julian Benkov
Telerik team
answered on 13 Jan 2012, 02:18 PM
Hi Empanada,

You can use this method to support this functionality:
private GridViewColumn[] FindColumns(string containsText)
{
    List<GridViewColumn> columns = new List<GridViewColumn>();
    foreach (var item in radGridView1.Columns)
    {
        if (item.Name.Contains(containsText))
        {
            columns.Add(item);
        }
    }
 
    return columns.ToArray();
}

I hope this helps. Let me know if you need further assistance.

Kind regards,
Julian Benkov
the Telerik team

SP1 of Q3’11 of RadControls for WinForms is available for download (see what's new).

Tags
GridView
Asked by
Empanada
Top achievements
Rank 1
Answers by
Julian Benkov
Telerik team
Share this question
or