I have added rows and columns dynamically in DataGridView, but here I want to remove Vertical and Horizontal scroll bar and also I want to display individual [row][columnn] value when I click on particular cell. I go through from here:
but I did not cleared my concept.
How to make it possible.
Below is part of my code:
private void Form1_Load(object sender, EventArgs e)
{
update();
}
public void update()
{
//Add Columns.
dataGridView1.ColumnCount = 3;
dataGridView1.Columns[0].Name = "NSE";
dataGridView1.Columns[1].Name = "BSE";
dataGridView1.Columns[2].Name = "MCX";
//Add Rows
ArrayList row = new ArrayList();
row.Add("1");
row.Add("2");
row.Add("3");
dataGridView1.Rows.Add(row.ToArray());
//2nd Row
row = new ArrayList();
row.Add("4");
row.Add("5");
row.Add("6");
dataGridView1.Rows.Add(row.ToArray());
//3rd Row
row = new ArrayList();
row.Add("7");
row.Add("8");
row.Add("9");
dataGridView1.Rows.Add(row.ToArray());
//4th Row
row = new ArrayList();
row.Add("10");
row.Add("11");
row.Add("12");
dataGridView1.Rows.Add(row.ToArray());
//5th Row
row = new ArrayList();
row.Add("13");
row.Add("14");
row.Add("15");
dataGridView1.Rows.Add(row.ToArray());
}
}}
You can try this......................
<div class="col-md-12" style="overflow-x: hidden; overflow-y: scroll; max-height: 400px; height: auto; max-width: 1000px; width: auto;">
<asp:GridView ID="DataGrid" runat="server" AutoGenerateColumns="False" Width="100%" CellPadding="5" AllowPaging="false" PageSize="10"> <Columns>
<asp:TemplateField ItemStyle-HorizontalAlign="Center" ItemStyle-Width="2%" HeaderStyle-HorizontalAlign="Center">
<HeaderTemplate> Sl No.
</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="lblSRNO" runat="server" Text='<%#Container.DataItemIndex+1 %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField Visible="False">
<ItemTemplate>
<asp:Label ID="lblByerId" runat="server" Text='<%# Eval("StyleId")%>' />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.