wpf DevExpress GridControl ColumnAutoWidth

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14031709/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 06:46:30  来源:igfitidea点击:

DevExpress GridControl ColumnAutoWidth

wpfdevexpress

提问by Kurtevich

The question is probably silly, but I spent half of the day looking for the answer with no luck.

这个问题可能很愚蠢,但我花了半天时间寻找答案,但没有运气。

I have a WPF view with DevExpress GridControl included (not developed by me). The problem is that when I click "Auto fit" option - it gets too wide with a horizontal scroll. The reason is long header titles, but it's Ok if they are wrapped into 2 lines.

我有一个包含 DevExpress GridControl 的 WPF 视图(不是我开发的)。问题是,当我单击“自动调整”选项时 - 水平滚动时它变得太宽了。原因是标题标题很长,但如果将它们包装成 2 行就可以了。

After some searching, I thought that what I need is ColumnAutoWidthproperty. The problem (here goes the silly part) is that I can't find out how to set it! Because of this I can't check if it works at least! There are no examples in documentation, and code autocomplete doesn't show it's presence anywhere. I had some assumptions but they appeared to be wrong.

经过一番搜索,我认为我需要的是ColumnAutoWidth属性。问题(这里是愚蠢的部分)是我不知道如何设置它!因此,我至少无法检查它是否有效!文档中没有示例,代码自动完成也不会在任何地方显示它的存在。我有一些假设,但它们似乎是错误的。

Can somebody please share XAML (or at least code-behind) example about how to access this property?

有人可以分享有关如何访问此属性的 XAML(或至少是代码隐藏)示例吗?

回答by Cedar

you just have to remove width element from your columns, and to set the autowidth element of the tableview. the link you posted is related xtraGrid control and it is a windows form not a WPF one, you have to control the width from the TableView.AutoWidth property.

您只需要从列中删除 width 元素,并设置 tableview 的 autowidth 元素。您发布的链接与 xtraGrid 控件相关,它是一个 Windows 窗体而不是 WPF 窗体,您必须从 TableView.AutoWidth 属性控制宽度。

Try to read the following documentation

尝试阅读以下文档

回答by Eldar

Your link is documentaion for WinForms grid. For Wpf GridColumn http://documentation.devexpress.com/#WPF/DevExpressXpfGridGridColumnMembersTopicAll

您的链接是 WinForms 网格的文档。对于 Wpf GridColumn http://documentation.devexpress.com/#WPF/DevExpressXpfGridGridColumnMembersTopicAll

As I understand you question - you want to fix column width. Try this

据我了解你的问题 - 你想固定列宽。尝试这个

<dxg:GridColumn Header="MyAwesomeColumn"
    Width="40"
    FixedWidth="True"
    FieldName="MyFieldName" />