自定义表头Datagrid

自定义的一个表头

  1 <bp:BasePage x:Class="NetReform.Pages.RealProbabiTableCompare"
  2         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4           xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  5       xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  6       xmlns:local="clr-namespace:NetReform"
  7       xmlns:bp="clr-namespace:NetReform.Pages"
  8                mc:Ignorable="d"
  9              xmlns:my="clr-namespace:WpfControls;assembly=WpfControls"
 10         Title="RealProbabiTableCompare" >
 11     <Grid >
 12
 13
 14         <Grid.Resources>
 15
 16             <!--背景色改变必须先设置cellStyle 因为cellStyle会覆盖rowStyle样式-->
 17             <Style  TargetType="DataGridRow">
 18                 <Setter Property="Background" Value="#F2F2F2" />
 19                 <Setter Property="Height" Value="25"/>
 20                 <Setter Property="Foreground" Value="Black" />
 21                 <Style.Triggers>
 22                     <!--隔行换色-->
 23                     <Trigger Property="AlternationIndex" Value="0" >
 24                         <Setter Property="Background" Value="#e7e7e7" />
 25                     </Trigger>
 26                     <Trigger Property="AlternationIndex" Value="1" >
 27                         <Setter Property="Background" Value="#f2f2f2" />
 28                     </Trigger>
 29
 30                     <Trigger Property="IsMouseOver" Value="True">
 31                         <Setter Property="Background" Value="LightGray"/>
 32                         <!--<Setter Property="Foreground" Value="White"/>-->
 33                     </Trigger>
 34
 35                     <Trigger Property="IsSelected" Value="True">
 36                         <Setter Property="Foreground" Value="Black"/>
 37                     </Trigger>
 38                 </Style.Triggers>
 39             </Style>
 40             <!--原来的样式-->
 41             <Style TargetType="TextBlock">
 42                 <Setter Property="HorizontalAlignment" Value="Center"/>
 43                 <Setter Property="VerticalAlignment" Value="Center"/>
 44                 <Setter Property="FontFamily" Value="Arial" />
 45                 <Setter Property="FontSize" Value="13" />
 46                 <Setter Property="Foreground" Value="#FFFAF0" />
 47             </Style>
 48
 49             <Style x:Key="br_bgGray" TargetType="Border">
 50                 <Setter Property="Background" Value="#dbdbdb"/>
 51             </Style>
 52
 53             <Style TargetType="Grid" x:Key="MyDataGrid">
 54                 <Setter Property="Background" >
 55                     <Setter.Value>
 56                         <!--垂直渐变-->
 57                         <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
 58                             <GradientStop Color="#555555" Offset="0.0"/>
 59                             <GradientStop Color="#111111" Offset="0.5"/>
 60                             <GradientStop Color="#555555" Offset="1.0"/>
 61                         </LinearGradientBrush>
 62                     </Setter.Value>
 63                 </Setter>
 64                 <Style.Triggers>
 65                     <Trigger Property="IsMouseOver" Value="True">
 66                         <Setter Property="Background" >
 67                             <Setter.Value>
 68                                 <!--垂直渐变-->
 69                                 <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
 70                                     <GradientStop Color="#FF111111" Offset="0.0"/>
 71                                     <GradientStop Color="#FF333333" Offset="1.0"/>
 72                                 </LinearGradientBrush>
 73                             </Setter.Value>
 74                         </Setter>
 75                     </Trigger>
 76                 </Style.Triggers>
 77             </Style>
 78
 79         </Grid.Resources>
 80
 81         <Grid.RowDefinitions>
 82             <RowDefinition Height="0" />
 83             <RowDefinition Height="35" />
 84             <RowDefinition Height="80"/>
 85             <RowDefinition Height="*"/>
 86             <RowDefinition Height="70"/>
 87         </Grid.RowDefinitions>
 88
 89         <!--第一行-->
 90
 91         <Label Content="概率预报对比" FontSize="20" Foreground="White" Grid.Row="1" Background="Gray"></Label>
 92
 93
 94             <!--第三行放表格头-->
 95         <Grid Margin="10,10,10,0" Grid.Row="2" Panel.ZIndex="2" Style="{StaticResource MyDataGrid}"  >
 96             <Grid.RowDefinitions>
 97                 <RowDefinition Height="4*" />
 98                 <RowDefinition Height="66*" />
 99             </Grid.RowDefinitions>
100             <Grid.ColumnDefinitions>
101                 <ColumnDefinition Width="4*"/>
102                 <ColumnDefinition Width="8*"/>
103                 <ColumnDefinition Width="16*"/>
104                 <ColumnDefinition Width="13*"/>
105                 <ColumnDefinition Width="18*"/>
106                 <ColumnDefinition Width="16*"/>
107                 <ColumnDefinition Width="20"/>
108             </Grid.ColumnDefinitions>
109             <Border BorderThickness="1" BorderBrush="Gray" CornerRadius="0" Grid.RowSpan="2">
110                 <TextBlock HorizontalAlignment="Center" >ID</TextBlock>
111             </Border>
112             <Border Grid.Column="1"  BorderThickness="1" BorderBrush="Gray" CornerRadius="0" Grid.RowSpan="2">
113                 <TextBlock HorizontalAlignment="Center" >Date</TextBlock>
114             </Border>
115
116
117
118             <Border Grid.Column="2" Grid.ColumnSpan="1" BorderThickness="1" BorderBrush="Gray" CornerRadius="0" Grid.RowSpan="2">
119                 <Grid >
120                     <Grid.RowDefinitions>
121                         <RowDefinition />
122                         <RowDefinition />
123                     </Grid.RowDefinitions>
124                     <Grid.ColumnDefinitions>
125                         <ColumnDefinition />
126                         <ColumnDefinition />
127                         <ColumnDefinition />
128                         <ColumnDefinition />
129                     </Grid.ColumnDefinitions>
130                     <Border Grid.Row="0" Grid.ColumnSpan="4" BorderThickness="0" BorderBrush="Gray" CornerRadius="0">
131                         <TextBlock Grid.Row="0" Grid.ColumnSpan="2">太阳耀斑概率</TextBlock>
132                     </Border>
133                     <Border Grid.Row="1" Grid.Column="0"  BorderThickness="0,1,1,0" BorderBrush="Gray" CornerRadius="0">
134                         <TextBlock Grid.Row="2" Grid.Column="0">obs</TextBlock>
135                     </Border>
136                     <Border  Grid.Row="1" Grid.Column="1" BorderThickness="0,1,0,0" BorderBrush="Gray" CornerRadius="0">
137                         <TextBlock Grid.Row="2" Grid.Column="1">1d(%)</TextBlock>
138                     </Border>
139                     <Border  Grid.Row="1" Grid.Column="2"  BorderThickness="1,1,0,0" BorderBrush="Gray" CornerRadius="0">
140                         <TextBlock Grid.Row="2" Grid.Column="1">2d(%)</TextBlock>
141                     </Border>
142                     <Border  Grid.Row="1" Grid.Column="3"  BorderThickness="1,1,0,0" BorderBrush="Gray" CornerRadius="0">
143                         <TextBlock Grid.Row="2" Grid.Column="1">3d(%)</TextBlock>
144                     </Border>
145                 </Grid>
146             </Border>
147
148
149             <Border Grid.Column="3" Grid.ColumnSpan="1" BorderThickness="1" BorderBrush="Gray" CornerRadius="0" Grid.RowSpan="2">
150                 <Grid >
151                     <Grid.RowDefinitions>
152                         <RowDefinition />
153                         <RowDefinition />
154                     </Grid.RowDefinitions>
155                     <Grid.ColumnDefinitions>
156                         <ColumnDefinition Width="4*" />
157                         <ColumnDefinition Width="3*"/>
158                         <ColumnDefinition Width="3*"/>
159                         <ColumnDefinition Width="3*"/>
160                     </Grid.ColumnDefinitions>
161                     <Border Grid.Row="0" Grid.ColumnSpan="4" BorderThickness="0" BorderBrush="Gray" CornerRadius="0">
162                         <TextBlock Grid.Row="0"  Grid.ColumnSpan="2">质子事件概率</TextBlock>
163                     </Border>
164                     <Border Grid.Row="1" Grid.Column="0"  BorderThickness="0,1,1,0" BorderBrush="Gray" CornerRadius="0">
165                         <TextBlock Grid.Row="2"  Grid.Column="0">obs</TextBlock>
166                     </Border>
167                     <Border  Grid.Row="1" Grid.Column="1" BorderThickness="0,1,0,0" BorderBrush="Gray" CornerRadius="0">
168                         <TextBlock Grid.Row="2" Grid.Column="1">1d(%)</TextBlock>
169                     </Border>
170                     <Border  Grid.Row="1" Grid.Column="2"  BorderThickness="1,1,0,0" BorderBrush="Gray" CornerRadius="0">
171                         <TextBlock Grid.Row="2" Grid.Column="1">2d(%)</TextBlock>
172                     </Border>
173                     <Border  Grid.Row="1" Grid.Column="3"  BorderThickness="1,1,0,0" BorderBrush="Gray" CornerRadius="0">
174                         <TextBlock Grid.Row="2" Grid.Column="1">3d(%)</TextBlock>
175                     </Border>
176                 </Grid>
177             </Border>
178
179             <Border Grid.Column="4" Grid.ColumnSpan="1" BorderThickness="1" BorderBrush="Gray" CornerRadius="0" Grid.RowSpan="2">
180                 <Grid >
181                     <Grid.RowDefinitions>
182                         <RowDefinition />
183                         <RowDefinition />
184                     </Grid.RowDefinitions>
185                     <Grid.ColumnDefinitions>
186                         <ColumnDefinition Width="9*" />
187                         <ColumnDefinition Width="3*" />
188                         <ColumnDefinition Width="3*"/>
189                         <ColumnDefinition Width="3*"/>
190                     </Grid.ColumnDefinitions>
191                     <Border Grid.Row="0" Grid.ColumnSpan="4" BorderThickness="0" BorderBrush="Gray" CornerRadius="0">
192                         <TextBlock Grid.Row="0" Grid.ColumnSpan="2">地磁暴概率</TextBlock>
193                     </Border>
194                     <Border Grid.Row="1" Grid.Column="0"  BorderThickness="0,1,1,0" BorderBrush="Gray" CornerRadius="0">
195                         <TextBlock Grid.Row="2" Grid.Column="0">obs</TextBlock>
196                     </Border>
197                     <Border  Grid.Row="1" Grid.Column="1" BorderThickness="0,1,0,0" BorderBrush="Gray" CornerRadius="0">
198                         <TextBlock Grid.Row="2" Grid.Column="1">1d(%)</TextBlock>
199                     </Border>
200                     <Border  Grid.Row="1" Grid.Column="2"  BorderThickness="1,1,0,0" BorderBrush="Gray" CornerRadius="0">
201                         <TextBlock Grid.Row="2" Grid.Column="1">2d(%)</TextBlock>
202                     </Border>
203                     <Border  Grid.Row="1" Grid.Column="3"  BorderThickness="1,1,0,0" BorderBrush="Gray" CornerRadius="0">
204                         <TextBlock Grid.Row="2" Grid.Column="1">3d(%)</TextBlock>
205                     </Border>
206                 </Grid>
207             </Border>
208
209
210             <Border Grid.Column="5" Grid.ColumnSpan="1" BorderThickness="1" BorderBrush="Gray" CornerRadius="0" Grid.RowSpan="2">
211                 <Grid >
212                     <Grid.RowDefinitions>
213                         <RowDefinition />
214                         <RowDefinition />
215                     </Grid.RowDefinitions>
216                     <Grid.ColumnDefinitions>
217                         <ColumnDefinition />
218                         <ColumnDefinition />
219                         <ColumnDefinition />
220                         <ColumnDefinition />
221                     </Grid.ColumnDefinitions>
222                     <Border Grid.Row="0" Grid.ColumnSpan="4" BorderThickness="0" BorderBrush="Gray" CornerRadius="0">
223                         <TextBlock Grid.Row="0" Grid.ColumnSpan="2">高能电子暴概率</TextBlock>
224                     </Border>
225                     <Border Grid.Row="1" Grid.Column="0"  BorderThickness="0,1,1,0" BorderBrush="Gray" CornerRadius="0">
226                         <TextBlock Grid.Row="2" Grid.Column="0">obs</TextBlock>
227                     </Border>
228                     <Border  Grid.Row="1" Grid.Column="1" BorderThickness="0,1,0,0" BorderBrush="Gray" CornerRadius="0">
229                         <TextBlock Grid.Row="2" Grid.Column="1">1d(%)</TextBlock>
230                     </Border>
231                     <Border  Grid.Row="1" Grid.Column="2"  BorderThickness="1,1,0,0" BorderBrush="Gray" CornerRadius="0">
232                         <TextBlock Grid.Row="2" Grid.Column="1">2d(%)</TextBlock>
233                     </Border>
234                     <Border  Grid.Row="1" Grid.Column="3"  BorderThickness="1,1,0,0" BorderBrush="Gray" CornerRadius="0">
235                         <TextBlock Grid.Row="2" Grid.Column="1">3d(%)</TextBlock>
236                     </Border>
237                 </Grid>
238             </Border>
239
240         </Grid>
241
242         <!--第四行放数据-->
243
244         <DataGrid Grid.Row="3"  Background="LightGray" Name="dg1" Margin="10,-27,10,0" Grid.Column="0" Grid.RowSpan="1" ItemsSource="{Binding}" AutoGenerateColumns="False"  CanUserAddRows="False" HorizontalScrollBarVisibility="Disabled"  AlternationCount="2" AreRowDetailsFrozen="True"  RowHeaderWidth="10" HeadersVisibility="Column" IsReadOnly="True"  HorizontalGridLinesBrush="LightGray" VerticalGridLinesBrush="LightGray" Foreground="#FF9C9D9D"  BorderBrush="Black" VerticalScrollBarVisibility="Visible">
245
246                 <DataGrid.CellStyle>
247                 <Style TargetType="DataGridCell">
248                     <Setter Property="Height" Value="30" />
249                     <Setter Property="Foreground" Value="Black" />
250                     <!--datagrid 垂直居中、水平左对齐 -->
251                     <Setter Property="Template">
252                         <Setter.Value>
253                             <ControlTemplate TargetType="{x:Type DataGridCell}">
254                                 <Grid Background="{TemplateBinding Background}">
255                                     <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
256                                 </Grid>
257                             </ControlTemplate>
258                         </Setter.Value>
259                     </Setter>
260                     <!--datagrid 设置选中行的背景色 -->
261                     <Style.Triggers >
262                         <Trigger Property="IsSelected" Value="True">
263                             <Setter Property="Background" Value="#00B0C4DE"></Setter>
264                         </Trigger>
265                     </Style.Triggers>
266                 </Style>
267             </DataGrid.CellStyle>
268             <DataGrid.Columns>
269                 <!--ID列-->
270                 <DataGridTemplateColumn Header="ID" Width="4*">
271                     <DataGridTemplateColumn.CellTemplate>
272                         <DataTemplate >
273                             <Border Height="30" Width="200">
274                                 <TextBlock Foreground="Gray" FontSize="16" Height="30" FontFamily="Microsoft YaHei"  HorizontalAlignment="Left" Margin="9,5,0,0"      Background="Transparent" Text="{Binding ID}"/>
275                             </Border>
276                         </DataTemplate>
277                     </DataGridTemplateColumn.CellTemplate>
278                 </DataGridTemplateColumn>
279                 <!--时间列-->
280                 <DataGridTextColumn Header="Date" FontSize="16" Binding="{Binding dayTime}" Width="8*" Foreground="Gray" FontFamily="Microsoft YaHei">
281                 </DataGridTextColumn>
282
283                 <!--<DataGridTextColumn Header="CNum" FontSize="12"  Binding="{Binding value}" Width="4*" Foreground="Gray"  FontFamily="Microsoft YaHei">
284
285                 </DataGridTextColumn>-->
286                 <DataGridTemplateColumn Header="obs" Width="4*" >
287                     <DataGridTemplateColumn.CellTemplate>
288                         <DataTemplate >
289                             <Border Height="30" Width="200" Style="{StaticResource ResourceKey=br_bgGray}">
290                                 <TextBlock Foreground="Gray" FontSize="16" Height="30" FontFamily="Microsoft YaHei"  HorizontalAlignment="Left" Margin="9,5,0,0"      Background="Transparent" Text="{Binding value}"/>
291                             </Border>
292                         </DataTemplate>
293                     </DataGridTemplateColumn.CellTemplate>
294                 </DataGridTemplateColumn>
295                 <DataGridTextColumn Header="1d" FontSize="16" Binding="{Binding pre1}" Width="4*" Foreground="Gray" FontFamily="Microsoft YaHei">
296                 </DataGridTextColumn>
297                 <DataGridTextColumn Header="2d" FontSize="16" Binding="{Binding pre2}" Width="4*" Foreground="Gray" FontFamily="Microsoft YaHei">
298                 </DataGridTextColumn>
299                 <DataGridTextColumn Header="3d" FontSize="16" Binding="{Binding pre3}" Width="4*" Foreground="Gray" FontFamily="Microsoft YaHei">
300                 </DataGridTextColumn>
301
302                 <!--kp列要更改的位置就是这里-->
303                 <!--<DataGridTextColumn Header="CNum" FontSize="12" Binding="{Binding valueu}" Width="4*" Foreground="Gray" FontFamily="Microsoft YaHei">
304                 </DataGridTextColumn>-->
305
306                 <DataGridTemplateColumn Header="obs" Width="4*" >
307                     <DataGridTemplateColumn.CellTemplate>
308                         <DataTemplate >
309                             <Border Height="30" Width="200" Style="{StaticResource ResourceKey=br_bgGray}">
310                                 <TextBlock Foreground="Gray" FontSize="16" Height="30" FontFamily="Microsoft YaHei"  HorizontalAlignment="Left" Margin="9,5,0,0"      Background="Transparent" Text="{Binding valueu}"/>
311                             </Border>
312                         </DataTemplate>
313                     </DataGridTemplateColumn.CellTemplate>
314                 </DataGridTemplateColumn>
315                 <DataGridTextColumn Header="1d" FontSize="16" Binding="{Binding pre1u}" Width="3*" Foreground="Gray" FontFamily="Microsoft YaHei">
316                 </DataGridTextColumn>
317                 <DataGridTextColumn Header="2d" FontSize="16" Binding="{Binding pre2u}" Width="3*" Foreground="Gray" FontFamily="Microsoft YaHei">
318                 </DataGridTextColumn>
319                 <DataGridTextColumn Header="3d" FontSize="16" Binding="{Binding pre3u}" Width="3*" Foreground="Gray" FontFamily="Microsoft YaHei">
320                 </DataGridTextColumn>
321
322
323                 <!--<DataGridTextColumn Header="CNum" FontSize="12" Binding="{Binding valuem}" Width="7*" Foreground="Gray" FontFamily="Microsoft YaHei">
324                 </DataGridTextColumn>-->
325                 <DataGridTemplateColumn Header="obs" Width="9*" >
326                     <DataGridTemplateColumn.CellTemplate>
327                         <DataTemplate >
328                             <Border Height="30" Width="200" Style="{StaticResource ResourceKey=br_bgGray}">
329                                 <TextBlock Foreground="Gray" FontSize="16" Height="30" FontFamily="Microsoft YaHei"  HorizontalAlignment="Left" Margin="9,5,0,0"      Background="Transparent" Text="{Binding valuem}"/>
330                             </Border>
331                         </DataTemplate>
332                     </DataGridTemplateColumn.CellTemplate>
333                 </DataGridTemplateColumn>
334
335                 <DataGridTextColumn Header="1d" FontSize="16" Binding="{Binding pre1m}" Width="3*" Foreground="Gray" FontFamily="Microsoft YaHei">
336                 </DataGridTextColumn>
337                 <DataGridTextColumn Header="2d" FontSize="16" Binding="{Binding pre2m}" Width="3*" Foreground="Gray" FontFamily="Microsoft YaHei">
338                 </DataGridTextColumn>
339                 <DataGridTextColumn Header="3d" FontSize="16" Binding="{Binding pre3m}" Width="3*" Foreground="Gray" FontFamily="Microsoft YaHei">
340                 </DataGridTextColumn>
341
342
343                 <!--<DataGridTextColumn Header="CNum" FontSize="12" Binding="{Binding valuec}" Width="4*" Foreground="Gray" FontFamily="Microsoft YaHei">
344                 </DataGridTextColumn>-->
345                 <DataGridTemplateColumn Header="obs" Width="4*" >
346                     <DataGridTemplateColumn.CellTemplate>
347                         <DataTemplate >
348                             <Border Height="30" Width="200" Style="{StaticResource ResourceKey=br_bgGray}">
349                                 <TextBlock Foreground="Gray" FontSize="16" Height="30" FontFamily="Microsoft YaHei"  HorizontalAlignment="Left" Margin="9,5,0,0"      Background="Transparent" Text="{Binding valuec}"/>
350                             </Border>
351                         </DataTemplate>
352                     </DataGridTemplateColumn.CellTemplate>
353                 </DataGridTemplateColumn>
354
355                 <DataGridTextColumn Header="1d" FontSize="16" Binding="{Binding pre1c}" Width="4*" Foreground="Gray" FontFamily="Microsoft YaHei">
356                 </DataGridTextColumn>
357                 <DataGridTextColumn Header="2d" FontSize="16" Binding="{Binding pre2c}" Width="4*" Foreground="Gray" FontFamily="Microsoft YaHei">
358                 </DataGridTextColumn>
359                 <DataGridTextColumn Header="3d" FontSize="16" Binding="{Binding pre3c}" Width="4*" Foreground="Gray" FontFamily="Microsoft YaHei">
360                 </DataGridTextColumn>
361
362
363             </DataGrid.Columns>
364         </DataGrid>
365
366
367
368         <!--第五行放数据处理后的值-->
369         <StackPanel Grid.Row="4" Orientation="Horizontal" HorizontalAlignment="Center">
370             <Label  Content="From:"  HorizontalContentAlignment="Right" Style="{StaticResource QueryLabel}"></Label>
371             <DatePicker Width="90" Height="25" x:Name="Dp_Start"  BorderThickness="1"  HorizontalAlignment="Center"  VerticalContentAlignment="Center" />
372
373             <Label  Content="To:"  HorizontalContentAlignment="Right" Style="{StaticResource QueryLabel}"></Label>
374             <DatePicker Width="90" Height="25" x:Name="Dp_End"  BorderThickness="1"  HorizontalAlignment="Center"  VerticalContentAlignment="Center" />
375             <Button  Name="Bt_CheckCurr" Style="{StaticResource Button_Image}"  Width="38" Height="38"  HorizontalAlignment="Left" ToolTip="查询"  >
376                 <Image Source="/NetReform;component/Images/Search.png" Width="35" Height="35" />
377             </Button>
378         </StackPanel>
379     </Grid>
380 </bp:BasePage>
时间: 2024-10-25 20:03:30

自定义表头Datagrid的相关文章

Django 支持自定义表头和根据数据库某字段生成多个sheet的excel下载

工作需要,需要做下载excel的功能,同时根据数据库的某个字段完成多sheet的功能. 由于用处较多,封装了一个函数. add_worksheet: 为生成多个sheet的方法 from io import BytesIO import xlsxwriter def download_excel(cursor, sql_field_index=False, custom_headers=False, sheet_title="worksheet_1"): ""&qu

gridview自定义表头

gridview为我们提供了丰富的接口,用于满足自定义需求. 通常asp:gridview会根据绑定的列Columns自动生成表头,展现在前台元素. 序号 类别 有时候需要复杂一些的表头. 序号 类别 数学 物理 化学 此时需要实现RowCreated事件 RowCreated提供了两个参数,重写表头. protected void RowCreated(object sender, GridViewRowEventArgs e) if (e.Row.RowType == DataControl

[Qt]自定义表头实现过滤功能

1. 写在前面 过滤功能源自项目上交互优化用户体验,在表头添加过滤符号实现过滤,替换以往在表格上方占用一行过滤项进行过滤. 2. 过滤提示 过滤提示就是三态图标(normal,hover,press).这三种状态的实现通过鼠标移动事件和鼠标点击事件来实现.具体实现如下: 1)hover状态在鼠标移动事件中实现 void CFilterHeaderView::mouseMoveEvent(QMouseEvent *e) { m_hover = logicalIndexAt(e->pos()); i

GridView 自定义表头

//修改表头 protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e) { switch (e.Row.RowType) { case DataControlRowType.Header: TableCellCollection tcHeader = e.Row.Cells; tcHeader.Clear(); //第一行表头 tcHeader.Add(new TableHeaderCell()); tc

WPF自定义控件与样式(7)-列表控件DataGrid与ListView自定义样式

一.前言 申明:WPF自定义控件与样式是一个系列文章,前后是有些关联的,但大多是按照由简到繁的顺序逐步发布的等,若有不明白的地方可以参考本系列前面的文章,文末附有部分文章链接. 本文主要内容: DataGrid自定义样式: ListView自定义样式: 二.DataGrid自定义样式 DataGrid是常用的数据列表显示控件,先看看实现的效果(动态图,有点大): DataGrid控件样式结构包括以下几个部分: 列头header样式 调整列头宽度的列分割线样式 行样式 行头调整高度样式 行头部样式

毕设问题(1)表格table的表头自定义、复合表头,组合表格

毕业设计,是一个web项目,遇到的些问题,记录下来.也许也有同样只知道一些,不是那么系统的学过的人,会遇到同样的问题,希望有所帮助. 百度知道有这样一个问题: bootstrap table 如何实现自定义表头?如图. 通常我们只看到是普通的二维表,但是有时候会有如上图的组合表头情况,这里需要使用th的两个可选属性rowspan和colspan分别是用来修改单元格的竖着和横着占的大小,实现上面的效果需要设置两行tr的thead,1,2,4的<th rowsapn="2">&

DataTables VS EasyUI DataGrid 基础应用 转

DataTables中文网推出了 第一篇 关于DataTables和其他表格插件比较后,为了把让这个比较更有意义,更能帮助到大家,DataTables中文网 做了问卷调查,根据小伙伴们的填写我归纳了一下,一个表格插件关注点在以下三个部分基础.高级的和进阶: 基础 排序 分页 搜索 美观 合理的配置 高级 单击和双击行事 选择高亮显示 增删改查 列宽拖动 数据导出 添加序号 进阶 支持的数据类型 行内编辑 合并单元格 自定义表头 高扩展性 易用的API 模块化 所以根据以上列出的这些功能点,Dat

Asp.net导出Excel续章(自定义合并单元格,非Office组件)

结合上次写的导出Excel方法,这次上头要求我将列头进行一下合并 以前的效果: 改进后的效果: 在上篇文章中写到了Excel的导出方法,这次为了避免在生产环境中使用Office组件,服务器各种权限配置的麻烦,这次就不使用Office组件来生成Excel了. 上篇文章:Asp.net导出Excel(HTML输出) 关键代码如下图: 说道这里,其实主要思路已经很明显了. 在数据绑定结束后,重新绘制表头替换掉原来的表头就行了. TableCell自定义表头的时候是table标签的,很方便. 另外发现了

解决bcp导出CSV文件没有表头

思路: 1.输出表头文件到指定目录 2.bcp导出csv文件到temp目录 3.将以上导出文件与表头文件合并 4.删除temp目录下的文件 实现: create proc exportCSV ( @id int ,@filepath varchar(8000),--输入参数 @re int output --输出参数 ) as declare @s varchar(8000) --csv文件的表头,你也可以自定义表头,但是为了与前端d3.js访问,直接就data1,data2了set @s='e