how to fix the column width of a listview in c# windows form?

后端 未结 4 777
野性不改
野性不改 2021-01-13 20:43

i have a listview i need to fix the column width of the listview so that at run time user cannot drag the columnheaders and resize it.....what is the procedure?? i have sear

4条回答
  •  不知归路
    2021-01-13 20:49

    One way of achieving this is by setting the Selector.IsEnabled to false.

    I'll put a code which I used in one of my applications that I was working on, it is simple you'll get it easily.

    ListView code (Focus on GridView's ColumnHeaderContainerStyle property) -

    
                        
    
                            
                                
                                
                                
                                
                                
                            
                        
                    
    

    For myHeaderStyle (Focus on Selector.IsEnabled property and Trigger for IsEnabled) -

    
    

    Now you won't be able to resize the columns and they will look disabled as well. For that just add a trigger on property IsEnabled then it will look the way you want it to.

提交回复
热议问题