如何設定UltraWebGrid的Cell內容可以換行
- Grid的Width設定成100%
- DisplayLayout中的StationaryMargins="Header"
- 使用TemplatedColumn,並在CellTemplate裡放個Label去處理,如下:
Width="10%">
<CellTemplate>
<asp:Label ID="Label1" runat="server" Text="<%# Container.Text %>" ></asp:Label>
</CellTemplate>
<Header>
<RowLayoutColumnInfo OriginX="1" />
</Header>
<Footer>
<RowLayoutColumnInfo OriginX="1" />
</Footer>
</igtbl:TemplatedColumn>
整個的aspx及vb
Height="200px">
<Bands>
<igtbl:UltraGridBand AddButtonCaption="Datas" BaseTableName="Datas" Key="Datas">
<AddNewRow View="NotSet" Visible="NotSet">
</AddNewRow>
<RowStyle CssClass="item" />
<SelectedRowStyle CssClass="HighlightRow" />
<RowAlternateStyle CssClass="Alitem">
</RowAlternateStyle>
<Columns>
<igtbl:TemplatedColumn BaseColumnName="CNO_CODE_DISPLAY" Key="CNO_CODE_DISPLAY"
Width="10%">
<CellTemplate>
<asp:Label ID="Label1" runat="server" Text="<%# Container.Text %>" ></asp:Label>
</CellTemplate>
<Header>
<RowLayoutColumnInfo OriginX="1" />
</Header>
<Footer>
<RowLayoutColumnInfo OriginX="1" />
</Footer>
</igtbl:TemplatedColumn>
<igtbl:TemplatedColumn BaseColumnName="HDL_DEPT" Key="HDL_DEPT" Width="10%">
<CellTemplate>
<asp:Label ID="Label2" runat="server" Text="<%# Container.Text %>"></asp:Label>
</CellTemplate>
<Header>
<RowLayoutColumnInfo OriginX="2" />
</Header>
<Footer>
<RowLayoutColumnInfo OriginX="2" />
</Footer>
</igtbl:TemplatedColumn>
<igtbl:TemplatedColumn BaseColumnName="SOURCE_NAME" Key="SOURCE_NAME"
Width="20%">
<CellTemplate>
<asp:Label ID="Label3" runat="server" Text="<%# Container.Text %>"></asp:Label>
</CellTemplate>
<Header>
<RowLayoutColumnInfo OriginX="3" />
</Header>
<Footer>
<RowLayoutColumnInfo OriginX="3" />
</Footer>
</igtbl:TemplatedColumn>
<igtbl:TemplatedColumn BaseColumnName="SOURCE_DATE" Key="SOURCE_DATE"
Width="20%">
<CellTemplate>
<asp:Label ID="Label4" runat="server" Text="<%# Container.Text %>"></asp:Label>
</CellTemplate>
<Header>
<RowLayoutColumnInfo OriginX="4" />
</Header>
<Footer>
<RowLayoutColumnInfo OriginX="4" />
</Footer>
</igtbl:TemplatedColumn>
<igtbl:TemplatedColumn BaseColumnName="SOURCE_SCNO" Key="SOURCE_SCNO"
Width="20%">
<CellTemplate>
<asp:Label ID="Label5" runat="server" Text="<%# Container.Text %>"></asp:Label>
</CellTemplate>
<Header>
<RowLayoutColumnInfo OriginX="5" />
</Header>
<Footer>
<RowLayoutColumnInfo OriginX="5" />
</Footer>
</igtbl:TemplatedColumn>
<igtbl:TemplatedColumn BaseColumnName="CNO_DESC" Key="CNO_DESC"
Width="10%">
<CellTemplate>
<asp:Label ID="Label5" runat="server" Text="<%# Container.Text %>"></asp:Label>
</CellTemplate>
<Header>
<RowLayoutColumnInfo OriginX="6" />
</Header>
<Footer>
<RowLayoutColumnInfo OriginX="6" />
</Footer>
</igtbl:TemplatedColumn>
<%-- <igtbl:TemplatedColumn BaseColumnName="HDL_USR" Key="HDL_USR"
Width="20%">
<CellTemplate>
<asp:Label ID="Label7" runat="server" Text="<%# Container.Text %>"></asp:Label>
</CellTemplate>
<Header>
<RowLayoutColumnInfo OriginX="7" />
</Header>
<Footer>
<RowLayoutColumnInfo OriginX="7" />
</Footer>
</igtbl:TemplatedColumn>--%>
<igtbl:UltraGridColumn BaseColumnName="HDL_USR" CellMultiline="Yes"
Key="HDL_USR" Width="20%">
<Header>
<RowLayoutColumnInfo OriginX="7" />
</Header>
<Footer>
<RowLayoutColumnInfo OriginX="7" />
</Footer>
</igtbl:UltraGridColumn>
</Columns>
<FilterOptions AllString="" EmptyString="" NonEmptyString="">
<FilterDropDownStyle BackColor="White" BorderColor="Silver" BorderStyle="Solid" BorderWidth="1px"
CustomRules="overflow:auto;" Font-Names="Verdana,Arial,Helvetica,sans-serif"
Font-Size="11px" Width="200px">
<Padding Left="2px" />
</FilterDropDownStyle>
<FilterHighlightRowStyle BackColor="#151C55" ForeColor="White">
</FilterHighlightRowStyle>
</FilterOptions>
<HeaderStyle CssClass="HeaderRow GridTitle" />
</igtbl:UltraGridBand>
</Bands>
<DisplayLayout AllowColSizingDefault="Free" AllowColumnMovingDefault="OnServer"
AllowDeleteDefault="Yes" AllowSortingDefault="OnClient" AutoGenerateColumns="False"
AllowUpdateDefault="Yes" BorderCollapseDefault="Separate"
HeaderClickActionDefault="SortMulti" Name="UltraWebGrid1"
RowHeightDefault="20px" RowSelectorsDefault="No"
SelectTypeRowDefault="Extended" StationaryMargins="Header" TableLayout="Fixed" Version="4.00"
>
<FrameStyle BackColor="Window" BorderColor="InactiveCaption"
BorderStyle="Solid" BorderWidth="1px" Font-Names="Microsoft Sans Serif"
Font-Size="8.25pt" Height="200px" Width="100%">
</FrameStyle>
<Pager MinimumPagesForDisplay="2">
<PagerStyle BackColor="LightGray" BorderStyle="Solid" BorderWidth="1px">
<BorderDetails ColorLeft="White" ColorTop="White" WidthLeft="1px"
WidthTop="1px" />
</PagerStyle>
</Pager>
<EditCellStyleDefault BorderStyle="None" BorderWidth="0px">
</EditCellStyleDefault>
<FooterStyleDefault BackColor="LightGray" BorderStyle="Solid" BorderWidth="1px">
<BorderDetails ColorLeft="White" ColorTop="White" WidthLeft="1px"
WidthTop="1px" />
</FooterStyleDefault>
<HeaderStyleDefault BackColor="LightGray" BorderStyle="Solid"
HorizontalAlign="Left">
<BorderDetails ColorLeft="White" ColorTop="White" WidthLeft="1px"
WidthTop="1px" />
</HeaderStyleDefault>
<RowStyleDefault BackColor="Window" BorderColor="Silver" BorderStyle="Solid"
BorderWidth="1px" Font-Names="Microsoft Sans Serif" Font-Size="8.25pt">
<Padding Left="3px" />
<BorderDetails ColorLeft="Window" ColorTop="Window" />
</RowStyleDefault>
<GroupByRowStyleDefault BackColor="Control" BorderColor="Window">
</GroupByRowStyleDefault>
<GroupByBox>
<BoxStyle BackColor="ActiveBorder" BorderColor="Window">
</BoxStyle>
</GroupByBox>
<AddNewBox Hidden="False">
<BoxStyle BackColor="Window" BorderColor="InactiveCaption" BorderStyle="Solid"
BorderWidth="1px">
<BorderDetails ColorLeft="White" ColorTop="White" WidthLeft="1px"
WidthTop="1px" />
</BoxStyle>
</AddNewBox>
<ActivationObject BorderColor="" BorderWidth="">
</ActivationObject>
<FilterOptionsDefault>
<FilterDropDownStyle BackColor="White" BorderColor="Silver" BorderStyle="Solid"
BorderWidth="1px" CustomRules="overflow:auto;"
Font-Names="Verdana,Arial,Helvetica,sans-serif" Font-Size="11px" Height="300px"
Width="200px">
<Padding Left="2px" />
</FilterDropDownStyle>
<FilterHighlightRowStyle BackColor="#151C55" ForeColor="White">
</FilterHighlightRowStyle>
<FilterOperandDropDownStyle BackColor="White" BorderColor="Silver"
BorderStyle="Solid" BorderWidth="1px" CustomRules="overflow:auto;"
Font-Names="Verdana,Arial,Helvetica,sans-serif" Font-Size="11px">
<Padding Left="2px" />
</FilterOperandDropDownStyle>
</FilterOptionsDefault>
</DisplayLayout>
</igtbl:UltraWebGrid>
BindGrid()
End Sub
Private Sub BindGrid()
Dim dtResult As New DataTable("nd")
dtResult.Columns.Add("CNO_CODE_DISPLAY", Type.GetType("System.String"))
dtResult.Columns.Add("HDL_DEPT", Type.GetType("System.String"))
dtResult.Columns.Add("SOURCE_NAME", Type.GetType("System.String"))
dtResult.Columns.Add("SOURCE_DATE", Type.GetType("System.String"))
dtResult.Columns.Add("SOURCE_SCNO", Type.GetType("System.String"))
dtResult.Columns.Add("CNO_DESC", Type.GetType("System.String"))
dtResult.Columns.Add("CNO_DT", Type.GetType("System.String"))
dtResult.Columns.Add("HDL_USR", Type.GetType("System.String"))
dtResult.Columns.Add("HDL_STAT_DESC", Type.GetType("System.String"))
dtResult.Columns.Add("SOURCE_SPEED", Type.GetType("System.String"))
dtResult.Columns.Add("SOURCE_SCUR", Type.GetType("System.String"))
dtResult.Columns.Add("NOW_DEPT_IDENT", Type.GetType("System.String"))
dtResult.Columns.Add("DOWN_DEPT_IDENT", Type.GetType("System.String"))
dtResult.Columns.Add("COMP_ID", Type.GetType("System.String"))
dtResult.Columns.Add("ACT", Type.GetType("System.String"))
dtResult.Columns.Add("END_DT", Type.GetType("System.String"))
dtResult.Columns.Add("CNO_CODE", Type.GetType("System.String"))
'新增資料到DataTable之中
dtResult.Rows.Add(New String() {"0980001350", "來文", "來文者,來文者來文者來文者來文者", "2009/12/07", "來文字號,來文字號哈!!哈!", "CNO_DESC", "CNO_DT", "HDL_USR中五有斗的三三的的三的的三", "HDL_STAT_DESC", "SOURCE_SPEED", "SOURCE_SCUR", "NOW_DEPT_IDENT", "DOWN_DEPT_IDENT", "COMP_ID", "ACT", "END_DT", "CNO_CODE"})
dtResult.Rows.Add(New String() {"中文字測試", "HDL_DEPT", "SOURCE_NAME SOURCE_DATE來文者", "2009/12/07", "SOURCE_SCNO", "CNO_DESC", "CNO_DT", "HDL_USR", "HDL_STAT_DESC", "SOURCE_SPEED", "SOURCE_SCUR", "NOW_DEPT_IDENT", "DOWN_DEPT_IDENT", "COMP_ID", "ACT", "END_DT", "CNO_CODE"})
UltraWebGrid1.DataSource = dtResult
UltraWebGrid1.DataBind()
End Sub
Hi,
亂馬客Blog已移到了 「亂馬客 : Re:從零開始的軟體開發生活」
請大家繼續支持 ^_^