F How to custom name of DataGridView Columns in C# | CodeTheta

How to custom name of DataGridView Columns in C#

August 17, 2019

First select the data from database table and load it to datagridview.

Below code dgvPurchaseStockEntry is a DataGridView and ["................."] is a table column name which will be replaced by custom HeaderText provided in below code.

Code :
dgvPurchaseStockEntry.Columns["product_code"].HeaderText = "HSN CODE";
dgvPurchaseStockEntry.Columns["product_name"].HeaderText = "PRODUCT NAME";
dgvPurchaseStockEntry.Columns["product_description"].HeaderText = "DESCRIPTION";
dgvPurchaseStockEntry.Columns["product_unit_price"].HeaderText = "UNIT PRICE";
dgvPurchaseStockEntry.Columns["product_category_name"].HeaderText = "CATEGORY";
dgvPurchaseStockEntry.Columns["product_quantity"].HeaderText = "QUANTITY";
dgvPurchaseStockEntry.Columns["product_purchased_date"].HeaderText = "PURCHASED DATE";
dgvPurchaseStockEntry.Columns["product_purchased_from"].HeaderText = "PURCHASED FROM";
dgvPurchaseStockEntry.Columns["product_invoice_number"].HeaderText = "INVOICE NUMBER";
dgvPurchaseStockEntry.Columns["product_cgst"].HeaderText = "CGST";
dgvPurchaseStockEntry.Columns["product_sgst"].HeaderText = "SGST";
dgvPurchaseStockEntry.Columns["product_igst"].HeaderText = "IGST";
dgvPurchaseStockEntry.Columns["product_total_price"].HeaderText = "TOTAL PRICE";

IDE Used To Test This Code : Microsoft Visual Studio.

Try this code in your computer for better understanding. Enjoy the code. If you have any Question you can contact us or mail us.We will reply you as soon as possible.

Post a Comment

PRODUCTS

LISTS OF PRODUCTS

SERVICES

SKILLS
SOFTWARE DEVELOPMENT
WEBSITE DEVELOPMENT
WEB HOSTING
BULK SMS SERVICE
SEO SERVICE
ANDROID APPS
QR CODE / BARCODE
HARDWARE SERVICE
OUR WORK AREA