/// <summary> /// 上移 下移 /// </summary> /// <param name="upOrDown"></param> private void upDown(string upOrDown) { if (dgvSetShort.SelectedRows.Count > 0) { int sort = Convert.ToInt32(dgvSetShort.SelectedRows[0].Cells[0].Value.ToString()); if (upOrDown == "up") { if (dgvSetShort.SelectedRows[0].Index != 0) { SetSort s = new SetSort(); s = SetSortList[sort - 1]; SetSortList[sort - 1] = SetSortList[sort - 2]; SetSortList[sort - 2] = s; SetSortList[sort - 1].sort = SetSortList[sort - 2].sort; SetSortList[sort - 2].sort = sort - 1; dgvSetShort.AutoGenerateColumns = false; dgvSetShort.DataSource = null; dgvSetShort.DataSource = SetSortList; dgvSetShort.Rows[dgvSetShort.SelectedRows[0].Index].Selected = false; dgvSetShort.Rows[sort - 2].Selected = true; dgvSetShort.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells; } else { return; } } else { if (dgvSetShort.SelectedRows[0].Index != dgvSetShort.Rows.Count - 1) { SetSort s = new SetSort(); s = SetSortList[sort - 1]; SetSortList[sort - 1] = SetSortList[sort]; SetSortList[sort] = s; SetSortList[sort - 1].sort = sort; SetSortList[sort].sort = sort + 1; dgvSetShort.AutoGenerateColumns = false; dgvSetShort.DataSource = null; dgvSetShort.DataSource = SetSortList; dgvSetShort.Rows[dgvSetShort.SelectedRows[0].Index].Selected = false; dgvSetShort.Rows[sort].Selected = true; dgvSetShort.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells; } else { return; } } } }
private void setSort() { SetSort s = null; foreach (int item in Driveway_IDList) { string DrivewaySql = "select Position_Name,Driveway_Name,Driveway_Type,Driveway_State,Position_State,Driveway_ID from View_DrivewayPosition where Driveway_ID=" + item + " order by Position_Name asc, Driveway_Name asc"; DataTable tab = LinQBaseDao.Query(DrivewaySql).Tables[0]; if (tab != null) { s = new SetSort(); s.text = "【" + tab.Rows[0]["Position_Name"].ToString() + "】" + " " + tab.Rows[0]["Driveway_Name"].ToString(); s.sort = SetSortList.Count + 1; s.id = Convert.ToInt32(tab.Rows[0]["Driveway_ID"]); SetSortList.Add(s); } } }