winform DataGrid 一选就可以选中一整行,不是选中单元格。 datagridwinform鼠标 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 第一个,有个属性,叫SelectEntireRow还是什么,就是选择整行的意思,改成True,默认是False。第二个,得重写一下Grid绘图那块,具体上网搜一搜------------------------------------------------------------------------------------------------请为参加博客之星的我投上一票感激之至 是DataGrid 不是 DataGridView 所以没有SelectEntireRow 这个属性 CurrentCellChanged事件中调用datagrid1.Select(datagrid1.CurrentRowIndex); 为什么不用DataGridView?这个东西可视化效果也好,属性也多 应该是WPF的DataGrid。1:修改DataGrid的SelecttionUnit=FullRow2:给你个dataGridRow的Style,自己修改颜色。 <Style TargetType="{x:Type DataGridRow}"> <Setter Property="SnapsToDevicePixels" Value="true"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type DataGridRow}"> <Border x:Name="DGR_Border" Background="Transparent" MouseEnter="DataGridRowMouseEnter" MouseLeave="DataGridRowMouseLeave" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" SnapsToDevicePixels="True"> <SelectiveScrollingGrid Background="Transparent"> <SelectiveScrollingGrid.ColumnDefinitions> <ColumnDefinition Width="Auto"/> <ColumnDefinition Width="*"/> </SelectiveScrollingGrid.ColumnDefinitions> <SelectiveScrollingGrid.RowDefinitions> <RowDefinition Height="*"/> <RowDefinition Height="Auto"/> </SelectiveScrollingGrid.RowDefinitions> <DataGridCellsPresenter Background="{TemplateBinding Background}" Grid.Column="1" ItemsPanel="{TemplateBinding ItemsPanel}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/> <DataGridDetailsPresenter Grid.Column="1" Grid.Row="1" SelectiveScrollingGrid.SelectiveScrollingOrientation="{Binding AreRowDetailsFrozen, ConverterParameter={x:Static SelectiveScrollingOrientation.Vertical}, Converter={x:Static DataGrid.RowDetailsScrollingConverter}, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}" Visibility="{TemplateBinding DetailsVisibility}"/> <DataGridRowHeader Background="Transparent" Grid.Row="0" Grid.RowSpan="2" SelectiveScrollingGrid.SelectiveScrollingOrientation="Vertical" Visibility="{Binding HeadersVisibility, ConverterParameter={x:Static DataGridHeadersVisibility.Row}, Converter={x:Static DataGrid.HeadersVisibilityConverter}, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"/> </SelectiveScrollingGrid> </Border> <ControlTemplate.Triggers> <Trigger Property="IsSelected" Value="True"> <!--选择行颜色--> <Setter Property="Background" TargetName="DGR_Border" Value="{DynamicResource dataGrid_Row_Selected}"/> </Trigger> <Trigger Property="IsMouseOver" Value="True"> <!--鼠标悬浮颜色--> <Setter Property="Background" TargetName="DGR_Border" Value="{DynamicResource dataGrid_Row_MouseOver}"/> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style> WebClient下载图片 调用系统API问题 AAC,APE,FLAC解码器都应该怎么用啊 在桌面上创建不带小箭头的快捷方式 DataTable.Column保留两位小位的问题 WPF 通过文件路径 获得文件图标 然后在一个image里显示 图片失真问题 请教浮点形(float)如何与双精度类型(double)相互转换,谢谢参与 Message DataGrid 问题 C#C#C#C#C#C#C#C#上课上课了~~~ 一段C#代码,能不能帮忙转成VB.NET的? 回归散分 + 提问:Unity的语法错误
第二个,得重写一下Grid绘图那块,具体上网搜一搜
------------------------------------------------------------------------------------------------
请为参加博客之星的我投上一票感激之至
是DataGrid 不是 DataGridView 所以没有SelectEntireRow 这个属性
1:修改DataGrid的SelecttionUnit=FullRow
2:给你个dataGridRow的Style,自己修改颜色。 <Style TargetType="{x:Type DataGridRow}">
<Setter Property="SnapsToDevicePixels" Value="true"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DataGridRow}">
<Border x:Name="DGR_Border" Background="Transparent" MouseEnter="DataGridRowMouseEnter"
MouseLeave="DataGridRowMouseLeave"
BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" SnapsToDevicePixels="True">
<SelectiveScrollingGrid Background="Transparent">
<SelectiveScrollingGrid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</SelectiveScrollingGrid.ColumnDefinitions>
<SelectiveScrollingGrid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</SelectiveScrollingGrid.RowDefinitions>
<DataGridCellsPresenter Background="{TemplateBinding Background}" Grid.Column="1" ItemsPanel="{TemplateBinding ItemsPanel}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
<DataGridDetailsPresenter Grid.Column="1" Grid.Row="1" SelectiveScrollingGrid.SelectiveScrollingOrientation="{Binding AreRowDetailsFrozen, ConverterParameter={x:Static SelectiveScrollingOrientation.Vertical}, Converter={x:Static DataGrid.RowDetailsScrollingConverter}, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}" Visibility="{TemplateBinding DetailsVisibility}"/>
<DataGridRowHeader Background="Transparent" Grid.Row="0" Grid.RowSpan="2" SelectiveScrollingGrid.SelectiveScrollingOrientation="Vertical" Visibility="{Binding HeadersVisibility, ConverterParameter={x:Static DataGridHeadersVisibility.Row}, Converter={x:Static DataGrid.HeadersVisibilityConverter}, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"/>
</SelectiveScrollingGrid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="True">
<!--选择行颜色-->
<Setter Property="Background" TargetName="DGR_Border" Value="{DynamicResource dataGrid_Row_Selected}"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<!--鼠标悬浮颜色-->
<Setter Property="Background" TargetName="DGR_Border" Value="{DynamicResource dataGrid_Row_MouseOver}"/>
</Trigger> </ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>