问题标签 [datagridtextcolumn]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
0 回答
541 浏览

wpf - 如果 datacontext 更改,Datagrid 列宽(非自动生成)不会更改

我有一个带有几个已定义 DataGridTextColumns 的 wpf 数据网格。当我绑定长字符串(100 个字符)时,有界列会根据内容正确增长。当数据上下文更改并且有界字符串变短(10 个字符)时,列宽不会缩小。

如果数据网格生成列 (AutoGenerateColumn="True"),则当数据上下文更改时,列宽会正确调整。

如何根据她的内容实现我定义的列进行调整?

0 投票
1 回答
56 浏览

c# - Need to convert CategoryID from Items table to CategoryNameA in Categories table inside view model

This is my first question and I apologize for my poor background knowledge. I've managed to fake my wake through a lot of C#/WPF/LINQ-to-SQL but I suspect that while I've gotten a lot of things working, I've done a lot of things the "wrong" way. I've Googled myself in circles over this question. My question seems like it should be simple and obvious.

I have two tables represented in my view model.

IQueryable<> Items is the items source for my datagrid. It has a column for CategoryID.

Categories are defined in a separate table with CategoryID and CategoryName.

I'd like to bind my a text column to Item's CategoryID and display the corresponding CategoryName from the Categories table.

I have accomplished it in what I think is the "wrong" way. It seems like there should be a much more straightforward way. I'd like to know whether my implementation is as silly as I think it is, and if so, what's the right way?

Here's my way:

Instead of using a text column, I'm using a (readonly) ComboBox column. I created an ObservableCollection<Category> Categories and I populate from the SQL database. I bind the items source of the ComboBox column to it and bind the selected value to Items and set the DisplayMemberPath to the CategoryName column (from Categories). It works but it just feels wrong!

Thank you!

0 投票
1 回答
4366 浏览

wpf - 如何使 WPF Datagrid 列不可聚焦?

我有一个 WPFDataGrid用于数据输入,但有些DataGridTextColumn只是信息,我已经设置了它们IsReadOnly="True",因此它们的单元格不会进入编辑模式。但是,他们仍然可以获得我想要避免的焦点。

有没有办法做到这一点?

0 投票
1 回答
418 浏览

binding - 加载用户控件时不会触发将 ColumnDefinition.Width 绑定到 DataGridTextColumn

我有一个 WPF 用户控件,它包含一个网格、一些文本框和一个DataGrid. 文本框是每列数据的过滤器,所以我希望它们保持在相关列之上。这很容易,除非用户调整DataGridTextColumn. 所以,我将 绑定Grid.ColumnDefinition.WidthDataGridTextColumn.Width.

它就像一个梦......在第一次调整大小之后。当表单最初打开时,文本框的宽度为 0。如何触发数据网格上的调整大小事件?目前我在 XAML 中进行绑定,是否应该等到控件初始化后再在代码中进行绑定?

0 投票
3 回答
23367 浏览

c# - 如何设置 DataGridTextColumn 文本颜色?

我正在尝试更改 DataGridTextColumn 的颜色。

这就是我正在做的事情:

文本设置正确,但颜色不会改变,我收到以下错误:

我应该怎么做才能使它起作用?

0 投票
1 回答
1446 浏览

wpf - 如何使用 DatagridTextColumn.ElementStyle 将 DatagridTextColumn 设为只读?

我可以使用 elementStyle 将 DatagridTextColumn IsReadOnly 绑定到 ViewModel 内的属性(此处为 IsReadOnlyProperty)吗?像这样的东西:

0 投票
2 回答
987 浏览

wpf - 当该列进入编辑模式时,有没有办法更改 DataGridTextColumn 的绑定?

我真正想做的就是更改StringFormata 上的特定绑定DataGridTextColumn,但由于这是由绑定定义的,我想我需要以某种方式更改整个绑定。

我想避免使用 aDataGridTemplateColumn的原因是因为 DataGridTextColumn 似乎有一些内置的基本功能,我会丢失并且必须编写代码来手动处理更多,例如:

  • 开始输入非编辑模式单元格的能力,该单元格自动进入编辑模式
  • 复制和粘贴数据(从 DataGrid 和 Excel 中)

当前绑定(所需的显示/读取模式绑定)

所需的编辑模式绑定

仅供参考,ReadDecimalFormat以 2 位精度显示十进制值,WriteDecimalFormat以显示输入的原始十进制值(全位精度,大多数情况下为 4 位)

0 投票
1 回答
1111 浏览

java - 具有多行的 CellTable 中的 GWT TextColumn

我想在 GWT 的 CellTable 中显示有关一本书的信息。比如它的内容。如何创建一个显示那么多文本的 TextColumn。多行或滚动条是我正在寻找的。

提前致谢

0 投票
1 回答
959 浏览

c# - 如何在 C# 中设置 DataGrid 单元格的值

我正在.NET 4.5 框架中编写应用程序。我DataGrid用来显示数据。我想添加新的文本列,并在每一行中为该列中的单元格分配文本值。我不知道该怎么做。我不知道如何绑定数据,或者我可以手动更改单元格内容吗?这对我来说是最方便的。

0 投票
4 回答
2075 浏览

wpf - WPF DataGridTextColumn 无法为浮点数据键入点

我有一个 WPF DataGrid 并使用 DataGridTextColumn 绑定到一个集合。Collection 中的项目有一些浮动属性。

当我的程序启动时,我修改了 DataGrid 中 float 属性的值,如果我输入一个整数值,它就可以正常工作。但是如果我输入 char 。对于浮点值, char 。无法输入。我必须先输入所有数字,然后跳到 . 键入 char 的位置。完成我的输入。

那我怎么打字。在我的情况下?

谢谢。