Datagridview is completely hidden for bindingsource the second time

允我心安 提交于 2020-02-26 02:02:37

问题


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:


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.



来源:https://stackoverflow.com/questions/59945448/datagridview-is-completely-hidden-for-bindingsource-the-second-time

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!