DataGrid
컨트롤의 TableStyles
컬렉션이 지정한 시점에 비어 있으며 DataGridTableStyle
컬렉션이 추가 될 때까지 남아 있습니다.
는 MappingName
속성에 대한 올바른 값을 설정하기위한 귀하의 제안을 사용하여, 내가 만들고 DataGrid
에서 요구 된 유일한 공공 필드를 포함하는 새로운 DataGridTableStyle
객체를 추가하여 원하는 결과를 달성했다.
// Create a DataGridTableStyle to hold all the columns to be displayed in the DataGrid
DataGridTableStyle myTableStyle = new DataGridTableStyle();
myTableStyle.MappingName = myBindingSource.GetListName(null); // This is the magic line
myTableStyle.GridColumnStyles.Clear();
// Add some DataGridColumnStyles
DataGridTextBoxColumn columnRowId = new DataGridTextBoxColumn();
columnRowId.MappingName = "idx"; //This must match the name of the public property
ColumnRowId.HeaderText = "Record";
tableStyleReportsSummary.GridColumnStyles.Add(columnRowId);
// Add the table style to the DataGrid
myDataGrid.TableStyles.Clear();
myDataGrid.TableStyles.Add(myTableStyle);
DataGridView 컨트롤 용입니까? – jp2code
아니요, .NET CF 3.5 DataGrid. –