Datagridview is completely hidden for bindingsourc

2020-05-08 08:49发布

private void populateListingGrid(){

try{

Dictionary<string, Object> responseMap = new Dictionary<string, object>();                
PaginationList newContractDetailsListingMsDTO = getNewContractDetailsListingMsDTO();                
ContractService createContractService = ContractServiceFactory.getInstance();
responseMap = createContractService.getContractListing();                
contractList = responseMap["contractListingMsDTOs"] as List<NewContractListingMsDTO>;
this.newContractListingMsDTOBindingSource.Clear();
             if (contractList != null && contractList.Count > 0)
             {
                 newContractListingMsDTOBindingSource.DataSource = contractList;
                 newContractListDataGridView.Refresh();
             }
}
catch (Exception e)
{
   logger.Info("populateListingGrid");
}
}

I am using the newContractListingMsDTOBindingSource as a bindingsource, which works perfectly fine when i open the datagrid for first time, when i try to reopen the datagridview in winforms, entire datagridview seems crashed nothing is visible not even the column header of the bindingsource.

Am i using all the binding source or binding data source code correctly?

1条回答
男人必须洒脱
2楼-- · 2020-05-08 09:41

After a lot of trial and error, i found the solution to the problem, it worked when i set the below property of the DataGridView

ColoumnHeadersHieghtSizeMode => AutoSize

If i change this property to DisableResizing/EnableResizing the Datagridview gets hidden the 2nd time. The probelem is not with the BindingSource or Datasource directly.

查看更多
登录 后发表回答