Link ArrayList to datagridview and display spesific data
-
Hi I would like to link ArrayList as datasource to datagridview I’ve defined the ArrayList arrList; arrList = new ArrayList(); //Add data to list arrList.Add(node_1); ... arrList.Add(node_n); dataGridView1.DataSource = arrList; Adding the link is OK, the problem is that I see all the members of nodes in datagridview and I wish to see only specific members in the grid. I try to manually add columns to grid and it didn’t help, I see all members of node in datagridview Please advice Thanks Ronen
-
Hi I would like to link ArrayList as datasource to datagridview I’ve defined the ArrayList arrList; arrList = new ArrayList(); //Add data to list arrList.Add(node_1); ... arrList.Add(node_n); dataGridView1.DataSource = arrList; Adding the link is OK, the problem is that I see all the members of nodes in datagridview and I wish to see only specific members in the grid. I try to manually add columns to grid and it didn’t help, I see all members of node in datagridview Please advice Thanks Ronen
-
Hi I would like to link ArrayList as datasource to datagridview I’ve defined the ArrayList arrList; arrList = new ArrayList(); //Add data to list arrList.Add(node_1); ... arrList.Add(node_n); dataGridView1.DataSource = arrList; Adding the link is OK, the problem is that I see all the members of nodes in datagridview and I wish to see only specific members in the grid. I try to manually add columns to grid and it didn’t help, I see all members of node in datagridview Please advice Thanks Ronen
See this is my code same as you want , this works for me correctly:
grdRequests.Columns.Clear(); loanRequests = //get your array list here grdRequests.DataSource = loanRequests; grdRequests.DataKeyNames = new string[] { "ID" }; CommandField SelectField = new CommandField(); SelectField.SelectText = "field1"; SelectField.ShowSelectButton = true; grdRequests.Columns.Add(SelectField); BoundField IDField = new BoundField(); IDField.DataField = "ID"; IDField.HeaderText = "field2"; grdRequests.Columns.Add(IDField); ... grdRequests.DataBind();
Human knowledge belongs to the world
-
Hi I would like to link ArrayList as datasource to datagridview I’ve defined the ArrayList arrList; arrList = new ArrayList(); //Add data to list arrList.Add(node_1); ... arrList.Add(node_n); dataGridView1.DataSource = arrList; Adding the link is OK, the problem is that I see all the members of nodes in datagridview and I wish to see only specific members in the grid. I try to manually add columns to grid and it didn’t help, I see all members of node in datagridview Please advice Thanks Ronen
The DataGridView will automatically show ALL public properties of your Node class. So you could do as musefan has suggested, or a possible alternative is to create a new class 'GriddableNode' which holds only the properties you wish to display, then create a list of some sort to use as the datasource for the DataGridView. OR you could edit the columns of the DataGridView, use the SmartTag for the gridview in the designer.
Henry Minute If you open a can of worms, any viable solution *MUST* involve a larger can.