|
-
Nov 8th, 2006, 06:19 PM
#1
Thread Starter
Lively Member
How to insert a new row to the top of the DataGridView
I have a datagridview to store a list of inventory transactions. I listed them in descending order by having the latest entered transaction to be shown on the top. When entering data, I have a few fields appearing immediately about the DataGridView in the main form to allow user to enter transaction data. When the use click the save button, I'll insert the new data into the datatable and to the DataGriidView. However, it ALWAYS inerts to the bottom of the DataGridView. It'll shows on the top ONLy when I exit the form and then reenters.
Question. When I ran the following statement, How can I "Add" the row to the TOP of the DataGridView such that it apears as the first row (on the top) ?
Dim str As String() = {Format(Last_Inventory_Row + 1, "##"), _
Format(Inventory_Date, Date_Medium_Fmt), _
Me.cboMaterial_Select_Category.Text, _
Format(Qty, Material_Fmt), _
Format(Purchased_Price, Price_Fmt), _
"", _
Current_User_Name}
Me.dgvMaterial_Inventory.Rows.Add(str)
Another option I can think of is to reverse the order and allows the new transaction to add to the bottom but then use the sort the table immediately such that it shows up on the top without existing the form. However, I do not know programmetically how to do it.
Can someone show me a sample code as how to programmatically sort a datagrid base on a particular column of data in it ?
Regards
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|