Click here to Skip to main content
15,886,873 members
Home / Discussions / C#
   

C#

 
GeneralRe: Generics argument detect a class type Pin
Pete O'Hanlon25-Mar-14 20:56
mvePete O'Hanlon25-Mar-14 20:56 
AnswerRe: Generics argument detect a class type Pin
Dave Kreskowiak25-Mar-14 9:07
mveDave Kreskowiak25-Mar-14 9:07 
GeneralRe: Generics argument detect a class type Pin
Simon_Whale25-Mar-14 10:12
Simon_Whale25-Mar-14 10:12 
QuestionHow can i set itextSharp PdfPTable column width Pin
devenv.exe25-Mar-14 1:11
professionaldevenv.exe25-Mar-14 1:11 
QuestionLoading SubFolders to DataGrid View - Please assist Pin
Mohan Subramani24-Mar-14 22:27
Mohan Subramani24-Mar-14 22:27 
AnswerRe: Loading SubFolders to DataGrid View - Please assist Pin
Pete O'Hanlon24-Mar-14 22:31
mvePete O'Hanlon24-Mar-14 22:31 
GeneralRe: Loading SubFolders to DataGrid View - Please assist Pin
Mohan Subramani25-Mar-14 0:34
Mohan Subramani25-Mar-14 0:34 
AnswerRe: Loading SubFolders to DataGrid View - Please assist Pin
Simon_Whale25-Mar-14 0:10
Simon_Whale25-Mar-14 0:10 
Below is some simple code that will get you started. This isn't the most flexible code that you can use but it should allow you to get started on the problem.

Personally I would build up a collection (Array, List or DataTable) and assign that as a data source.

Also it will only show the folders in the directory which you have specified and not each folders sub directory's.

C#
DataGridViewTextBoxColumn first = new DataGridViewTextBoxColumn();
first.Name = "Name";
first.HeaderText = "Name";

dataGridView1.Columns.Add(first);

DataGridViewTextBoxColumn second = new DataGridViewTextBoxColumn();
second.Name = "FullName";
second.HeaderText = "Full Path";

dataGridView1.Columns.Add(second);

DirectoryInfo dir = new DirectoryInfo(@"d:\documents");
foreach (DirectoryInfo subDir in dir.GetDirectories())
{
    dataGridView1.Rows.Add(new string[] { subDir.Name, subDir.FullName });
}

Every day, thousands of innocent plants are killed by vegetarians.

Help end the violence EAT BACON

QuestionWhere Is the Current Free Download Of Visual C# ? Pin
C-P-User-324-Mar-14 3:09
C-P-User-324-Mar-14 3:09 
AnswerRe: Where Is the Current Free Download Of Visual C# ? Pin
Pete O'Hanlon24-Mar-14 3:16
mvePete O'Hanlon24-Mar-14 3:16 
GeneralRe: Where Is the Current Free Download Of Visual C# ? Pin
C-P-User-324-Mar-14 3:18
C-P-User-324-Mar-14 3:18 
GeneralRe: Where Is the Current Free Download Of Visual C# ? Pin
Pete O'Hanlon24-Mar-14 3:22
mvePete O'Hanlon24-Mar-14 3:22 
GeneralRe: Where Is the Current Free Download Of Visual C# ? Pin
C-P-User-324-Mar-14 3:29
C-P-User-324-Mar-14 3:29 
GeneralRe: Where Is the Current Free Download Of Visual C# ? Pin
Pete O'Hanlon24-Mar-14 7:37
mvePete O'Hanlon24-Mar-14 7:37 
AnswerRe: Where Is the Current Free Download Of Visual C# ? Pin
Kenneth Haugland24-Mar-14 3:16
mvaKenneth Haugland24-Mar-14 3:16 
GeneralRe: Where Is the Current Free Download Of Visual C# ? Pin
C-P-User-324-Mar-14 3:20
C-P-User-324-Mar-14 3:20 
QuestionRe: Where Is the Current Free Download Of Visual C# ? Pin
Kenneth Haugland24-Mar-14 3:25
mvaKenneth Haugland24-Mar-14 3:25 
AnswerRe: Where Is the Current Free Download Of Visual C# ? Pin
C-P-User-324-Mar-14 3:30
C-P-User-324-Mar-14 3:30 
AnswerRe: Where Is the Current Free Download Of Visual C# ? Pin
BobJanova24-Mar-14 3:56
BobJanova24-Mar-14 3:56 
GeneralRe: Where Is the Current Free Download Of Visual C# ? Pin
C-P-User-324-Mar-14 4:20
C-P-User-324-Mar-14 4:20 
GeneralRe: Where Is the Current Free Download Of Visual C# ? Pin
BobJanova24-Mar-14 4:40
BobJanova24-Mar-14 4:40 
GeneralRe: Where Is the Current Free Download Of Visual C# ? Pin
harold aptroot24-Mar-14 7:40
harold aptroot24-Mar-14 7:40 
GeneralRe: Where Is the Current Free Download Of Visual C# ? Pin
BobJanova24-Mar-14 8:07
BobJanova24-Mar-14 8:07 
GeneralRe: Where Is the Current Free Download Of Visual C# ? Pin
Kenneth Haugland24-Mar-14 11:10
mvaKenneth Haugland24-Mar-14 11:10 
QuestionUsing nonce for authentication Pin
TygerBS24-Mar-14 2:21
TygerBS24-Mar-14 2:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.