<asp:Button ID="btMoveRight" runat="server" Text=" &gt;&gt; " OnClick="btMoveRight_Click" />
<asp:Button ID="btMoveLeft" runat="server" Text=" &lt;&lt; " OnClick="btMoveLeft_Click" />

 

// 右移按鍵的函式
protected void btMoveRight_Click(object sender, EventArgs e)
{
// 將所選到的項目新增至lbGroupUser
for (int i = 0; i < lbNotGroupUser.Items.Count; i++)
{
if (lbNotGroupUser.Items[i].Selected)
{
lbGroupUser.Items.Add(lbNotGroupUser.Items[i]);
lbNotGroupUser.Items.RemoveAt(i);
i--;
}
}
lbGroupUser.ClearSelection();
}

//左移按鍵的函式
protected void btMoveLeft_Click(object sender, EventArgs e)
{
// 將所選到的項目新增至lbNotGroupUser
for (int i = 0; i < lbGroupUser.Items.Count; i++)
{
if (lbGroupUser.Items[i].Selected)
{
lbNotGroupUser.Items.Add(lbGroupUser.Items[i]);
lbGroupUser.Items.RemoveAt(i);
i--;
}
}
lbNotGroupUser.ClearSelection();
}

文章標籤
全站熱搜
創作者介紹
創作者 JoyceHsu1126 的頭像
JoyceHsu1126

Joyce Hsu 的部落格

JoyceHsu1126 發表在 痞客邦 留言(0) 人氣(345)