datagrid 相关问题

一个图形用户界面元素,用于显示数据的表格视图。

IsReadOnlyProperty.OverrideMetadata 中断 WPF DataGrid 子类中的鼠标双击命令

我有一个 DataGrid 的子类,它提供了一些额外的功能并修改了它的一些属性的默认值。特别是一件事是我希望网格是只读的......

回答 1 投票 0

为什么 DataGridComboBoxColumn 的默认值没有出现在 C# WPF 中的 DataGrid 中?

项目主题: 我有一个 MS Access 2003 adp VBA 项目可以连接到 SQL Server 数据库,现在我正在将该项目转换为 C# WPF,我将把数据直接保存到 SQL Server da ...

回答 1 投票 0

更改列标题背景 DataGrid UWP

我目前正在查看来自 Nuget Microsoft.Toolkit.Uwp.UI.Controls.DataGrid xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls" 的 UWP DataGrid,我想更改单个列

回答 3 投票 0

WPF MVVM Datagid with ComboBox column set ComboBox Background with alternate color

我编辑了 ComboBox Style 以将 ComboBox ToggleButton 的背景绑定到 ComboBox Background 属性(这显然是唯一的方法)。 ... <p>我已经编辑了 <pre><code>ComboBox</code></pre> <pre><code>Style</code></pre> 以将 <pre><code>ComboBox</code></pre> <pre><code>ToggleButton&#39;s Background</code></pre> 绑定到 <pre><code>ComboBox Background</code></pre> 属性(显然是唯一的方法)。</p> <pre><code>... &lt;Style x:Key=&#34;ComboBoxToggleButton&#34; TargetType=&#34;{x:Type ToggleButton}&#34;&gt; ... &lt;Setter Property=&#34;Template&#34;&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType=&#34;{x:Type ToggleButton}&#34;&gt; &lt;Border x:Name=&#34;templateRoot&#34; BorderBrush=&#34;{StaticResource ComboBox.Static.Border}&#34; BorderThickness=&#34;{TemplateBinding BorderThickness}&#34; Background=&#34;{TemplateBinding Background}&#34; SnapsToDevicePixels=&#34;true&#34;&gt; &lt;= BINDING HERE &lt;Border x:Name=&#34;splitBorder&#34; BorderBrush=&#34;Transparent&#34; BorderThickness=&#34;1&#34; HorizontalAlignment=&#34;Right&#34; Margin=&#34;0&#34; SnapsToDevicePixels=&#34;true&#34; Width=&#34;{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}&#34;&gt; &lt;Path x:Name=&#34;arrow&#34; Data=&#34;F1 M 0,0 L 2.667,2.66665 L 5.3334,0 L 5.3334,-1.78168 L 2.6667,0.88501 L0,-1.78168 L0,0 Z&#34; Fill=&#34;{StaticResource ComboBox.Static.Glyph}&#34; HorizontalAlignment=&#34;Center&#34; Margin=&#34;0&#34; VerticalAlignment=&#34;Center&#34;/&gt; &lt;/Border&gt; &lt;/Border&gt; &lt;ControlTemplate.Triggers&gt; ... </code></pre> <p>所以这个<pre><code>XAML</code></pre>代码现在可以工作了:</p> <pre><code>&lt;ComboBox Background=&#34;Yellow&#34; /&gt; </code></pre> <p>现在我有 <pre><code>Datagrid</code></pre> 和 <pre><code>ComboBox</code></pre> 列,我想将替代行颜色绑定到 <pre><code>ComboBox Background</code></pre> 属性:</p> <pre><code>&lt;DataGrid AutoGenerateColumns=&#34;False&#34; Name=&#34;datagrid1&#34; Height=&#34;auto&#34; ItemsSource=&#34;{Binding SourceList}&#34; SelectedItem=&#34;{Binding SelectedSource}&#34; BorderThickness=&#34;1&#34; AlternatingRowBackground=&#34;#FFFFFFCC&#34; HorizontalGridLinesBrush=&#34;#FFA0A0A0&#34; VerticalGridLinesBrush=&#34;#FFA0A0A0&#34; SelectionUnit=&#34;FullRow&#34; HeadersVisibility=&#34;Column&#34; GridLinesVisibility=&#34;Horizontal&#34; CanUserResizeRows=&#34;False&#34; VerticalContentAlignment=&#34;Center&#34; BorderBrush=&#34;DarkGray&#34; HorizontalAlignment=&#34;Stretch&#34;&gt; &lt;DataGrid.Columns&gt; &lt;DataGridTextColumn Header=&#34;NameText&#34; Binding=&#34;{Binding NameText}&#34; Width=&#34;*&#34;/&gt; &lt;DataGridTemplateColumn Width = &#34;*&#34; Header = &#34;Names&#34;&gt; &lt;DataGridTemplateColumn.CellTemplate&gt; &lt;DataTemplate&gt; &lt;ComboBox VerticalContentAlignment = &#34;Center&#34; ItemsSource = &#34;{Binding DataContext.NamesList, RelativeSource ={RelativeSource Findancestor, AncestorType = { x:Type Window}}}&#34; SelectedItem=&#34;{Binding Name, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}&#34; DisplayMemberPath=&#34;Name&#34;&gt; &lt;ComboBox.Style&gt; &lt;Style TargetType=&#34;ComboBox&#34; BasedOn=&#34;{StaticResource {x:Type ComboBox}}&#34;&gt; &lt;Setter Property=&#34;Background&#34; Value=&#34;Yellow&#34;/&gt; &lt;Style.Triggers&gt; &lt;DataTrigger Binding=&#34;{Binding Path=ItemsControl.AlternationIndex, ElementName=datagrid1}&#34; Value=&#34;1&#34;&gt; &lt;Setter Property=&#34;Background&#34; Value=&#34;#FFFFFFCC&#34;&gt;&lt;/Setter&gt; &lt;/DataTrigger&gt; &lt;/Style.Triggers&gt; &lt;/Style&gt; &lt;/ComboBox.Style&gt; &lt;/ComboBox&gt; &lt;/DataTemplate&gt; &lt;/DataGridTemplateColumn.CellTemplate&gt; &lt;/DataGridTemplateColumn&gt; &lt;/DataGrid.Columns&gt; &lt;/DataGrid&gt; </code></pre> <p>如何实现?</p> </question> <answer tick="false" vote="0"> <p>用途:</p> <pre><code>&lt;DataTrigger Binding=&#34;{Binding Path=ItemsControl.AlternationIndex, RelativeSource={RelativeSource AncestorType={x:Type DataGridRow}}}&#34; Value=&#34;1&#34;&gt; &lt;Setter Property=&#34;Background&#34; Value=&#34;#FFFFFFCC&#34;/&gt; &lt;/DataTrigger&gt; </code></pre> </answer> </body></html>

回答 0 投票 0

wpf datagridcheckboxcolumn:如何启用/禁用复选框

我有一个带有 DataGridCheckBoxColumn 的 DataGrid。网格具有与对象列表的绑定。我想要的是,如果选中了 N 个复选框,未选中的将被禁用,但我不知道该怎么做

回答 3 投票 0

WPF DataGrid - DataGridTextColumn decimal/double/float input with PropertyChanged

我在使用 UpdateSourceTrigger=PropertyChanged 的 DataGridTextColumn 中输入十进制(双精度/浮点数)时遇到问题。 (1) 我搜索了几个网站,很多人建议将其更改为 LostFocus ...

回答 3 投票 0

DataGrid 的某些单元格不显示内容,除非双击

我正在使用 C# 在 WPF 应用程序中创建绑定的 DataGrid,绑定工作正常,就像我在 observablecollection 列表中添加或删除对象一样。但是,在编辑...的属性时...

回答 1 投票 0

给 DataGridTextColumn 一个静态值

在 WPF DataGrid 中,我们可以通过这种方式绑定 DataGridTextColumn 值。 如果我想给...怎么办

回答 1 投票 0

失败的 prop 类型:prop `rows` 在 `ForwardRef(DataGrid)` 中标记为 required,但其值为 `undefined`

代码是: 返回 ( 添加新用户 代码是: return ( <div className="datatable"> <div className="datatableTitle"> Add New User <Link to="/users/new" className="link"> Add New </Link> </div> <DataGrid className="datagrid" rows={list} columns={userColumns.concat(actionColumn)} pageSize={9} rowsPerPageOptions={[9]} checkboxSelection getRowId = { (row)=>row._id} /> </div> ); 我正在从 lamadev 的 youtube 教程创建一个预订 MERN 应用程序。 我不确定这里出了什么问题。 这里需要初始化数组: const [list, setList] = useState(); 成为 const [list, setList] = useState([]); 这是因为 React 的工作方式。第一次运行代码时,您的提取不会返回值。 阅读有关反应生命周期的信息。 https://www.w3schools.com/react/react_lifecycle.asp 如果您使用加载指示器阻止执行屏幕截图中的代码,那么您的错误是当您捕获时您完全忽略了该错误。所以记录错误并处理它。 要在没有任何列表数据的情况下呈现页面,请执行rows={list ?? []}以确保列表为空而不是空/未定义。 你解决问题了吗因为我有同样的问题

回答 2 投票 0

在 React MUI DataGrid 中获取复选框选择上的行项目

我从 API 获取数据并使用 React MUI DataGrid 显示它。 我启用了复选框选择,我想获取所选行的特定单元格项并将它们保存在列表中。 对于 E...

回答 3 投票 0

Material UI 数据网格,选择所有子项时自动选择组列

我正在使用具有行选择和多列分组的 Material UI 数据网格。 I would like to update the selected state of my grouping field whenever all its children are selected.我怎么能

回答 0 投票 0

How to get multiple selection in WPF datagrid using stylet mvvm?

我有一个在数据网格上显示数据的 VB.net WPF 应用程序。 我需要获取选定的行; XAML 我有一个在数据网格上显示数据的 VB.net WPF 应用程序。 我需要获取选定的行; XAML <DataGrid Grid.Column="1" Loaded="{s:Action RefreshMyTable}" Grid.ColumnSpan="5" Grid.Row="1" Grid.RowSpan="17" SelectionChanged="{s:Action test}" AutoGenerateColumns="True" ColumnWidth="*" SelectedValuePath="ID" SelectedItem="{Binding Path=SelectedItemDG, Mode=TwoWay}" ItemsSource="{Binding myCollection}"> 虚拟机 Public Property SelectedItemDG As New myObject Public Property SelectedItemDGCollection As New BindableCollection(Of myObject) Public Sub test(ByVal sender As Object, ByVal e As EventArgs) SelectedItemDGCollection.Add(SelectedItemDG) End Sub Public Sub btntestmultiselection() For Each x In SelectedItemDGCollection Debug.WriteLine(x.ID) Next End Sub` 如果只选择一行,我可以选择项目,但如果以这种方式选择多行,我只会得到最新的。 我在这里找到了一些提到属性 SelectedItems 而不是 SelectedItem 的答案,但我在 wpf datagrid 中找不到它。当然,我会避免代码隐藏,因为我使用的是 mvvm。 有什么建议吗?

回答 0 投票 0

如何在 React 中记忆材料 ui Datagrid

我无法在 React 中记忆我的 Material UI Datagridtable const Mockdata = [{id: 1, 用户: "john", 学校: "LAL" }, {id: 2, 用户: "Ruby", 学校: "LAL" }] 常数

回答 0 投票 0

C#-WPF 防止 itemsource 改变时触发数据网格的复选框事件

我有一个包含各种单元格的数据网格。我使用一个复选框事件将 x 金额添加到全局余额帐户。数据仅在一年内有效。因此,如果我更改当前年份(通过梳理...

回答 0 投票 0

DatagridPro 不会用反应测试库开玩笑地渲染列,即使在我给它列之后也是如此。测试用例越来越失败

有人提到使用 disableVirtualization,但它仍然没有渲染,而且排序也不起作用。是否需要在列中传递 id?但我不想在表列中显示 id 但是,hidea ...

回答 0 投票 0

在 DataGrid 中对列进行排序时拖放无法工作

行的重新排列最初按预期工作,但如果列已排序,拖放行将不起作用。 此外,如果我取消数据网格中的列排序,拖放功能会起作用...

回答 1 投票 0

DataGrid 中 Button 的 Command 属性遇到绑定错误

我正在尝试使用 WPF DataGrid 中的按钮。我的数据网格 ItemsSource 绑定到一个类,但我希望按钮在 ViewModel 中调用 ICommand。我已经看过十几个或更多关于这个的帖子,并且

回答 1 投票 0

列排序时“DataGrid”拖放不起作用(WPF MVVM)

我按照下面的例子 https://www.c-sharpcorner.com/UploadFile/raj1979/drag-and-drop-datagrid-row-in-wpf/ 实现拖放功能,但由于某些原因,当列标题...

回答 0 投票 0

DataGrid 在编辑单元格时保留所有选定的行

我有一个 WPF DataGrid,我在其中按标签显示音乐列表,例如;艺术家、标题、年份等。通过 .itemsource 填充 我想要实现的是多选行,然后...

回答 0 投票 0

.NET 6 WinUI 3 社区工具包 Datagrid 以编程方式更新单元格值

我有一个带按钮的社区工具包数据网格。单击该按钮会触发一个事件,该事件调用一个方法来更新绑定到该按钮的 Text 的 Selected 属性。绑定的物品是属性...

回答 0 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.