/// <summary> /// 反选 /// </summary> public override void UCSelectFan() { foreach (Control ctl in panGroup.Controls) { if (ctl is UCFabLTile) { UCFabLTile ucf = (UCFabLTile)ctl; ucf.UCChecked = !ucf.UCChecked; } } }
/// <summary> /// 全选 /// </summary> public override void UCSelectAll() { foreach (Control ctl in panGroup.Controls)// { if (ctl is UCFabLTile) { UCFabLTile ucf = (UCFabLTile)ctl; ucf.UCChecked = true; } } }
/// <summary> /// 取消一个选项,外部调用 /// </summary> /// <param name="p_ISN"></param> public override void UCCancelOne(string p_ISN) { foreach (Control ctl in panGroup.Controls) { if (ctl is UCFabLTile) { UCFabLTile ucf = (UCFabLTile)ctl; if (ucf.UCISN == p_ISN) { ucf.UCChecked = false; } } } }
/// <summary> /// 磁贴选择改变事件 /// </summary> /// <param name="sender"></param> void UCFabLTile_CheckChanged(object sender) { if (tempTileShifFlag)//在执行Shift事件中,不执行,防止死循环 { return; } tempTileShifFlag = true; UCFabLTile ucft = (UCFabLTile)sender; DataRow[] drA = UCDataSource.Select(" BoxNo=" + SysString.ToDBString(ucft.UCISN)); if (drA.Length == 1) { drA[0]["SelectFlag"] = SysConvert.ToInt32(ucft.UCChecked); } if ((Control.ModifierKeys & Keys.Shift) == Keys.Shift) //按住了Shift键盘 { if (UCCurrnetFocusIndex != -1) //前一聚焦行号已存在 { for (int i = UCCurrnetFocusIndex + 1; i < ucft.UCRowIndex; i++) //防止死循环调用 { UCDataSource.Rows[i]["SelectFlag"] = ucft.UCChecked; } foreach (Control ctl in panGroup.Controls) { if (ctl is UCFabLTile) { UCFabLTile ucf = (UCFabLTile)ctl; if (ucf.UCRowIndex >= UCCurrnetFocusIndex + 1 && ucf.UCRowIndex <= ucft.UCRowIndex) { ucf.UCChecked = ucft.UCChecked; } } } } } UCCurrnetFocusIndex = ucft.UCRowIndex; tempTileShifFlag = false; }
/// <summary> /// 创建磁贴一个 /// </summary> /// <param name="p_XIndex">水平序号</param> /// <param name="p_YIndex">垂直序号</param> UCFabLTile CreateFabTileOne(int p_XIndex, int p_YIndex) { int splitpixel = 2;//间隔像素 int tempWidth = 175, tempHeight = 175; UCFabLTile ucft = new UCFabLTile(); ucft.Location = new System.Drawing.Point(p_XIndex * tempWidth + splitpixel * (p_XIndex + 1), p_YIndex * tempHeight + splitpixel * (p_YIndex + 1)); ucft.Name = "ucft" + (10000 * p_YIndex + p_XIndex); ucft.Size = new System.Drawing.Size(tempWidth, tempHeight); ucft.TabIndex = 1000 * p_YIndex + p_XIndex; //ucft.UCBackColorIndex = p_ColorIndex; ucft.object_CheckedChanged += new UCFabLTileCheckChanged(UCFabLTile_CheckChanged);//关联委托事件 //ucft.MouseClick += new MouseEventHandler(panGroup_MouseClick);//快速点击及滚动用 ucft.UCControl_RowIndexChanged += new UCFabRowIndexChanged(UCControl_RowIndexChanged); if (UCAllowKPFlag) { ucft.ContextMenuStrip = cMenuLoadFab; } return(ucft); }
/// <summary> /// 创建磁贴 /// </summary> /// <param name="dtSource">数据源,列0/1/2/3/4:选择标志/BoxNo/卷号/数量/缸号</param> /// <param name="p_ColumnCount">列数量</param> void CreateFabTile(DataTable dtSource, int p_ColumnCount) { RemoveUserCtl(panGroup); //panGroup.Controls.Clear();//清除界面上所有控件 for (int i = 0; i < dtSource.Rows.Count; i++) { int xIndex = i % p_ColumnCount; //水平 取余 int yIndex = i / p_ColumnCount; //垂直 取整 int colorIndex = 1; //色系 //if (xIndex % 2 == 1)//取余 //{ // colorIndex = 2; //} UCFabLTile ucft = CreateFabTileOne(xIndex, yIndex); ucft.IniValue(dtSource.Rows[i]["BoxNo"].ToString() , new string[] { dtSource.Rows[i]["SubSeq"].ToString(), dtSource.Rows[i]["Qty"].ToString(), dtSource.Rows[i]["JarNum"].ToString(), dtSource.Rows[i]["Weight"].ToString(), dtSource.Rows[i]["GoodsLevel"].ToString(), dtSource.Rows[i]["Yard"].ToString() } , SysConvert.ToBoolean(SysConvert.ToInt32(dtSource.Rows[i]["SelectFlag"])), colorIndex); ucft.UCRowIndex = i;//磁贴序号 panGroup.Controls.Add(ucft); } }