How can I set the width of each column in a GridView?

0

How can I set the width of each column to a GridView in the following case below?

 <div style="width: 1000px; height: 400px; overflow: scroll">
    <asp:GridView ID="Grid" runat="server" AutoGenerateColumns="False" CellPadding="6"
      HeaderStyle-CssClass="Cabec">
      <EmptyDataTemplate>
        Nenhum Registro Encontrado
      </EmptyDataTemplate>
      <Columns>
        <asp:BoundField HeaderText="Nome Filial" DataField="NomeFilial" HeaderStyle-HorizontalAlign="Left"
          ItemStyle-Width="150px" ItemStyle-Wrap="false" />
        <asp:BoundField HeaderText="Nr Titulo " DataField="NrTitulo" HeaderStyle-HorizontalAlign="Left"  HeaderStyle-Width="250px" ItemStyle-Width="250px" />
        <asp:BoundField HeaderText="Dt Emissão" DataField="DtEmissao" DataFormatString="{0:dd/MM/yyyy HH:mm}"
          HeaderStyle-HorizontalAlign="Left"  ItemStyle-Width="150px" ItemStyle-Wrap="false"/>
        <asp:BoundField HeaderText="Dt Vencimento" DataField="DtVencimento" DataFormatString="{0:dd/MM/yyyy HH:mm}"
          HeaderStyle-HorizontalAlign="Left"  ItemStyle-Width="150px" ItemStyle-Wrap="false" />
        <asp:BoundField HeaderText="Valor Titulo" DataField="ValorTitulo" HeaderStyle-HorizontalAlign="Left" />
        <asp:BoundField HeaderText="Dias Vencido" DataField="DiasVencido" HeaderStyle-HorizontalAlign="Left" />
        <asp:BoundField HeaderText="Valor Bruto Titulo" DataField="ValorBrutoTitulo" HeaderStyle-HorizontalAlign="Left" />
        <asp:BoundField HeaderText="Valor Baixado" DataField="ValorBaixado" HeaderStyle-HorizontalAlign="Left" />
        <asp:BoundField HeaderText="Valor Receber" DataField="ValorReceber" HeaderStyle-HorizontalAlign="Left" />
        <asp:BoundField HeaderText="Ocorrência Geral" DataField="OcorrenciaGeral" HeaderStyle-HorizontalAlign="Left" />
        <asp:BoundField HeaderText="Razão Social" DataField="RazaoSocial" HeaderStyle-HorizontalAlign="Left" />
        <asp:BoundField HeaderText="Nome Obra" DataField="NomeObra" HeaderStyle-HorizontalAlign="Left" />
        <asp:BoundField HeaderText="Nome" DataField="Nome" HeaderStyle-HorizontalAlign="Left" />
        <asp:BoundField HeaderText="Tipo Cobrança" DataField="TipoCobranca" HeaderStyle-HorizontalAlign="Left" />
      </Columns>
    </asp:GridView>
  </div>

I've already tried ItemStyle-Width="150px" and HeaderStyle-Width="250px" , but the columns do not respect the size set as shown below

I want to set a size for each column so that both the header and the items are a reasonable size.

    
asked by anonymous 10.11.2015 / 20:08

1 answer

2

Use HeaderStyle-CssClass="larguraMinima and create css:

.larguraMinima{
     min-width: 140px;
} 
    
11.11.2015 / 20:40