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

Asked

Viewed 683 times

0

How can I set the width of each column in one 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 tried to ItemStyle-Width="150px" and the HeaderStyle-Width="250px", but the columns do not respect the size defined according to the image below inserir a descrição da imagem aqui

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

1 answer

2


Use HeaderStyle-CssClass="larguraMinima and create the css:

.larguraMinima{
     min-width: 140px;
} 

Browser other questions tagged

You are not signed in. Login or sign up in order to post.