Stack Exchange
Merge columns and rows in DataGridView
Hi I'm using datagridview in vb.net to show the data from this query:
Select 0 As 
Serial,Agent.Agent,ProductionSlip.AgentID,Product.Product,Category,
Unit.Unit,IsNULL(ProductStock.AgSlipID,0) As 
AgSlipID,ProductStock.ProductID,  Sum(Case When TransTypeID=23 then 
IsNULL(Qty,0) else 0 end) As SlipQty,  Sum(Case When TransTypeID=24 
then IsNULL(Qty,0) else 0 end) As DisQty,  Sum(Case When 
TransTypeID=23 then IsNULL(Qty,0) else -IsNULL(Qty,0) end) As BalQty  
From ProductStock  Left Join ProductionSlip On 
ProductStock.AgSlipID=ProductionSlip.ProductionSlipID  Left Join 
Agent On ProductionSlip.AgentID=Agent.AgentID  Left Join Product On 
ProductStock.ProductID=Product.ProductID  Left Join Unit On 
Product.UnitID=Unit.UnitID  Where TransTypeID In (23,24) Group By 
Agent.Agent,ProductionSlip.AgentID,Product.Product,Category,
Unit.Unit,
IsNULL(ProductStock.AgSlipID,0),ProductStock.ProductID  
Having Sum(Case When TransTypeID=23 then IsNULL(Qty,0) else -
IsNULL(Qty,0) end)>0  Order By Product.Product"

I want to join rows and columns as shown in the image below

