How do you fix columns on a Listview?

Asked

Viewed 170 times

2

I got the following Listview below, precise leaves the first 3 columns fixed and allow the rest to scroll.

<td colspan="4">
  <div class="GradeDados" style="position: relative; width: 1000px; height: 400px;
    z-index: 1; overflow: scroll;">
    <asp:ListView ID="livCamposForm" runat="server" OnItemDataBound="livCamposForm_OnItemDataBound"
      DataKeyNames="IdCampoFormulario">
      <LayoutTemplate>
        <table>
          <tr>
            <th>
              <asp:Label ID="lblCodigo" runat="server">Código</asp:Label>
            </th>
            <th>
              <asp:Label ID="lblClasificacao" runat="server">Clasificação</asp:Label>
            </th>
            <th>
              <asp:Label ID="lblDescricao" runat="server">Descrição</asp:Label>
            </th>
            <th>
              <asp:Label ID="lblJaneiro" runat="server">Janeiro</asp:Label>
            </th>
            <th>
              <asp:Label ID="lblFevereiro" runat="server">Fevereiro</asp:Label>
            </th>
            <th>
              <asp:Label ID="lblMarco" runat="server">Março</asp:Label>
            </th>
            <th>
              <asp:Label ID="lblAbril" runat="server">Abril</asp:Label>
            </th>
            <th>
              <asp:Label ID="lblMaio" runat="server">Maio</asp:Label>
            </th>
            <th>
              <asp:Label ID="lblJunho" runat="server">Junho</asp:Label>
            </th>
            <th>
              <asp:Label ID="lblJulho" runat="server">Julho</asp:Label>
            </th>
            <th>
              <asp:Label ID="lblAgosto" runat="server">Agosto</asp:Label>
            </th>
            <th>
              <asp:Label ID="lblSetembro" runat="server">Setembro</asp:Label>
            </th>
            <th>
              <asp:Label ID="lblOutubro" runat="server">Outubro</asp:Label>
            </th>
            <th>
              <asp:Label ID="lblNovembro" runat="server">Novembro</asp:Label>
            </th>
            <th>
              <asp:Label ID="lblDezembro" runat="server">Dezembro</asp:Label>
            </th>
            <th>
              <asp:Label ID="lblTotal" runat="server">Total</asp:Label>
            </th>
          </tr>
          <tr id="itemplaceholder" runat="server">
          </tr>
        </table>
        </div>
      </LayoutTemplate>
      <ItemTemplate>
        <tr class="<%#setClass(Container.DataItem)%>">
          <td>
            <asp:Label ID="lblCodigoEdit" class="<%#setClass(Container.DataItem)%>" runat="server"
              Text='<%# Eval("Codigo")%>' />
          </td>
          <td>
            <asp:Label ID="lblClasificacaoEdit" runat="server" Text='<%# Eval("Clasificacao")%>' />
          </td>
          <td>
            <asp:Label ID="lblDescricaoEdit" runat="server" Text='<%# Eval("Descricao")%>' />
          </td>
          <td>
            <uc7:NumericEdit ID="NuJaneiro" runat="server" Text='<%# DecimalPontoVigula(Eval("Janeiro"))%>' />
          </td>
          <td>
            <uc7:NumericEdit ID="NuFevereiro" runat="server" Text='<%# DecimalPontoVigula(Eval("Fevereiro"))%>' />
          </td>
          <td>
            <uc7:NumericEdit ID="NuMarco" runat="server" Text='<%# DecimalPontoVigula(Eval("Marco"))%>' />
          </td>
          <td>
            <uc7:NumericEdit ID="NuAbril" runat="server" Text='<%# DecimalPontoVigula(Eval("Abril"))%>' />
          </td>
          <td>
            <uc7:NumericEdit ID="NuMaio" runat="server" Text='<%# DecimalPontoVigula(Eval("Maio"))%>' />
          </td>
          <td>
            <uc7:NumericEdit ID="NuJunho" runat="server" Text='<%# DecimalPontoVigula(Eval("Junho"))%>' />
          </td>
          <td>
            <uc7:NumericEdit ID="NuJulho" runat="server" Text='<%# DecimalPontoVigula(Eval("Julho"))%>' />
          </td>
          <td>
            <uc7:NumericEdit ID="NuAgosto" runat="server" Text='<%# DecimalPontoVigula(Eval("Agosto"))%>' />
          </td>
          <td>
            <uc7:NumericEdit ID="NuSetembro" runat="server" Text='<%# DecimalPontoVigula(Eval("Setembro"))%>' />
          </td>
          <td>
            <uc7:NumericEdit ID="NuOutubro" runat="server" Text='<%# DecimalPontoVigula(Eval("Outubro"))%>' />
          </td>
          <td>
            <uc7:NumericEdit ID="NuNovembro" runat="server" Text='<%# DecimalPontoVigula(Eval("Novembro"))%>' />
          </td>
          <td>
            <uc7:NumericEdit ID="NuDezembro" runat="server" Text='<%# DecimalPontoVigula(Eval("Dezembro"))%>' />
          </td>
          <td>
            <uc7:NumericEdit ID="NuTotal" ReadOnly="true" runat="server" Text='<%# DecimalPontoVigula(Eval("Total"))%>' />
          </td>
        </tr>
      </ItemTemplate>
    </asp:ListView>
  </div>
</td>

form

  • What have you tried?

  • I researched on the subject what I found was the use of the event "Columnwidthchanging" : e.Newwidth = listview.Columns[e. Columnindex]. Width;.... but Listview does not have the property "Columns"...

1 answer

4


Being a DataGridView, you can set the property Frozen as true:

this.livCamposForm.Columns["lblCodigo"].Frozen = true;

With ListView I believe it is not possible to do this. The definition of columns is quite different and the object is not specialized.

  • I got it, I even got it with Gridview, but I need the fields to receive values and this effect I only know with the use of Listview.

  • @Marconciliosouza as well preciso que os campos recebam valores e esse efeito só conheço com a utilização do ListView? You say, each field receives a value at a given time?

  • @jbueno, see the image, in the fifth row of the column "January" the user has the option to type a decimal value, after that I use the value to make some calculations and saved in the bank. When the user starts rolling the grid until December the description disappears and this makes it difficult to understand who is filling the form.

Browser other questions tagged

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