In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article focuses on "how to prevent the EditvalueChanged event of a drop-down list control from entering an endless loop". Interested friends may wish to take a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "how to prevent the EditvalueChanged event of a drop-down list control from entering an endless loop."
When the drop-down list control is selected, another one is determined to be empty. If return needs to clear the drop-down list, the Changed event will be triggered again. The solution is to put the judgment of null value on the outermost layer, as shown in the following code:
Private void gluCOATemplate_EditValueChanged (object sender, EventArgs e) {try {if (gluCOATemplate.Text! = "") {string sCoaId = gluCOATemplate.Text; string sBacthId = txtLotID.Text If (txtLotID.Text = = "") {CommonFunction.ShowMsgBox ("check batch number cannot be empty"); InitgdvCoaItem (); gluCOATemplate.Text = ""; txtLotID.Focus (); return } if (gluCOATemplate.Text = = "") {CommonFunction.ShowMsgBox ("Please select template ID"); gluCOATemplate.Focus (); return } if (txtLotID.Text! = "& & sCoaId! =") {DataTable dt = new DataTable (); dt = QCMLIST.QCM_View_COA_Detail (sCoaId, sBacthId) If (dt! = null) {udcGVNewDelCtrl1.RecordCount = dt.Rows.Count; / / DevGridControlHelper.BindData (gdcCOAItem, dt); DevGridControlHelper.BindData (gdcCOAItem, dt, new int [] {1,1,1,1,1}) } else {InitgdvCoaItem ();} catch (Exception ex) {CommonFunction.ShowMsgBox (ex.Message) Return;}}
=
Prevent added data primary key conflicts:
At the beginning, the maximum value found without a primary key is + 1.
Int iSeq = InTag.coa_ list [I] .item _ seq; if (iSeq = = 0) / / if the incoming Seq is empty (0), take the largest + 1 in the database, otherwise save {List uQcmcoaitemlist = ctx.UQcmcoaitem.Where (t = > t.PkgNoticeNo = = sPkgId & & t.Factory = = sFactory) .OrderByDescending (t = > t.ItemSeq) .OrderByDescending () If (uQcmcoaitemlist! = null) {iSeq = uQcmcoaitemlist [0] .ItemSeq + 1 } else {iSeq = 1 }} UQcmcoaitem uQcmcoaItem = new UQcmcoaitem {PkgNoticeNo = sPkgId, Factory = sFactory, ItemSeq = iSeq TestingResult = InTag.coa_ list [I] .testing _ result, TestingItem = InTag.coa_ list [I] .testing _ item, TestingSpec = InTag.coa_ list [I] .testing _ specification, TestingMethod = InTag.coa_ list [I] .testing _ method Dimens = InTag.coa_ List.dimensions, CreateTime = DBGV._dbc.DB_GetSysTime (), CreateUserId = InTag._cmn_in._user_id} Ctx.UQcmcoaitem.Add (uQcmcoaItem)
However, when adding multiple pieces of Seq=0 data, the maximum value of + 1 checked from the database will cause the primary key of the data to be added in the past few days to conflict, because the transaction has not yet been committed and the Seq is Max+1.
Solution: add an int variable (count=0) to the loop, and after each Max+1, add count:
Int count = 0 for (int I = 0; I)
< InTag.coa_list.Length; i++){ if (InTag.coa_list[i].step == 'I') { int iSeq = InTag.coa_list[i].item_seq; if (iSeq == 0) { List uQcmcoaitemlist = ctx.UQcmcoaitem.Where(t =>T.PkgNoticeNo = = sPkgId & & t.Factory = = sFactory) .OrderByDescending (t = > t.ItemSeq). ToList (); if (uQcmcoaitemlist! = null) {iSeq = uQcmcoaitemlist [0]. ItemSeq + 1 counters; count++ } else {iSeq = 1 }} UQcmcoaitem uQcmcoaItem = new UQcmcoaitem {PkgNoticeNo = sPkgId, Factory = sFactory, ItemSeq = iSeq TestingResult = InTag.coa_ list [I] .testing _ result, TestingItem = InTag.coa_ list [I] .testing _ item, TestingSpec = InTag.coa_ list [I] .testing _ specification, TestingMethod = InTag.coa_ list [I] .testing _ method Dimens = InTag.coa_ List.dimensions, CreateTime = DBGV._dbc.DB_GetSysTime (), CreateUserId = InTag._cmn_in._user_id} Ctx.UQcmcoaitem.Add (uQcmcoaItem);} else {sMsgCode = "QCM-0004"; return GlobalConstant.FAIL }} ctx.SaveChanges (); transaction.Commit ()
Height setting for the GridLookUpEdit drop-down list:
Set AutoHeight in properties to false, and then set the value of size
At this point, I believe you have a deeper understanding of "how to prevent the EditvalueChanged event of a drop-down list control from entering an endless loop". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.