Click here to Skip to main content
15,887,485 members
Home / Discussions / C#
   

C#

 
AnswerRe: De-smellifying some code... Pin
MidwestLimey16-Aug-07 7:24
professionalMidwestLimey16-Aug-07 7:24 
GeneralRe: De-smellifying some code... Pin
martin_hughes16-Aug-07 12:12
martin_hughes16-Aug-07 12:12 
GeneralRe: De-smellifying some code... Pin
Luc Pattyn16-Aug-07 13:03
sitebuilderLuc Pattyn16-Aug-07 13:03 
GeneralRe: De-smellifying some code... Pin
martin_hughes17-Aug-07 6:50
martin_hughes17-Aug-07 6:50 
GeneralRe: De-smellifying some code... Pin
MidwestLimey16-Aug-07 17:20
professionalMidwestLimey16-Aug-07 17:20 
AnswerRe: De-smellifying some code... Pin
PhilDanger16-Aug-07 8:15
PhilDanger16-Aug-07 8:15 
AnswerRe: De-smellifying some code... Pin
Leslie Sanford16-Aug-07 12:35
Leslie Sanford16-Aug-07 12:35 
Questionanonymous method runs "too many times" Pin
gericooper16-Aug-07 5:53
gericooper16-Aug-07 5:53 
Greetings,

Below code would do the following upon user clicks the button:
if user clicks on a specific cell on the instantiated form's datagridview, the appropriate row's data is copied into the caller form's datagridview.

Problem is: the anonym method is fired as many times as user clicks "this" form's button (in order to show up the other form, whose datagridview contains the data to be copied onto "this" form' gridview) BUT I'd like it to be fired only ONCE at a time. thanks for any thread, g (placing "return" didn't help) Confused | :confused:

<br />
public int I = 0;<br />
 private void btnHozzaadas_Click(object sender, EventArgs e)<br />
        {<br />
            Guid[] array = new Guid[15];<br />
         <br />
<br />
        <br />
            tetelArErAnSzerk.Owner = this;<br />
            <br />
            tetelArErAnSzerk.anyagDataGridView.CellClick += delegate<br />
            {<br />
<br />
                if (tetelArErAnSzerk.anyagDataGridView.CurrentCell.OwningColumn.DataPropertyName == "AnyagHozzaadas")<br />
                {<br />
<br />
                    DataView datatableView = felhasznAnyagSzallitasBindingSource.List as DataView;<br />
                    DataRowView rowView = datatableView.AddNew();<br />
<br />
                    Debmut9DataSet.Felhaszn_AnyagSzallitasRow felhasznaltanyagdatarow = (felhasznaltanyagszallitasDataGridView.Rows[I].DataBoundItem as DataRowView).Row<br />
                    as Debmut9DataSet.Felhaszn_AnyagSzallitasRow;<br />
<br />
                    rowView["TetelArId"] = (tetelArBindingSource.Current as DataRowView)["TetelArId"];<br />
                    felhasznaltanyagdatarow.AnyagId = new Guid();<br />
                    Guid anyagid = ((tetelArErAnSzerk.anyagDataGridView.CurrentRow.DataBoundItem as DataRowView).Row as<br />
                    Debmut9DataSet.AnyagRow).AnyagId;<br />
                    array[I] = anyagid;<br />
                    if (I == 0)<br />
<br />
                    { felhasznaltanyagdatarow.AnyagId = anyagid; }<br />
<br />
                     <br />
                    if (I > 0)<br />
                    {<br />
                        for (int J = 0; J < felhasznaltanyagszallitasDataGridView.Rows.Count - 1; J++)<br />
                        {<br />
                            <br />
                            for (int K = 1; K < felhasznaltanyagszallitasDataGridView.Rows.Count - 1; K++)<br />
                            {<br />
                                if (J == K)<br />
                                {<br />
                                    K++;<br />
                                }<br />
                                if (array[J] == array[K])<br />
                                {<br />
                                    MessageBox.Show("Component exists, Cant be added again!", "Not added...", MessageBoxButtons.OK, MessageBoxIcon.Warning);<br />
                                    felhasznAnyagSzallitasBindingSource.Remove(rowView);<br />
                                    <br />
                                    <br />
                                    return;<br />
                                }<br />
<br />
                            }<br />
<br />
<br />
                        }<br />
                    }<br />
<br />
                    felhasznaltanyagdatarow.AnyagId = anyagid;<br />
<br />
                    felhasznaltanyagszallitasDataGridView.Rows[I].Cells["Anyagszallfelhaszn_Megnevezes"].Value = ((tetelArErAnSzerk.anyagDataGridView.CurrentRow.DataBoundItem as DataRowView).Row as<br />
                       Debmut9DataSet.AnyagRow).AnyagNev;<br />
                    felhasznaltanyagszallitasDataGridView.Rows[I].Cells["Anyagszallfelhaszn_Szall_szolg"].Value = ((tetelArErAnSzerk.anyagDataGridView.CurrentRow.DataBoundItem as DataRowView).Row as<br />
                       Debmut9DataSet.AnyagRow).AnyagSzallito;<br />
                    felhasznaltanyagszallitasDataGridView.Rows[I].Cells["Anyagszallfelhaszn_Me"].Value = tetelArErAnSzerk.anyagDataGridView.CurrentRow.Cells["Anyag_Me"].FormattedValue;<br />
                    felhasznaltanyagszallitasDataGridView.Rows[I].Cells["Anyagszallfelhaszn_ear"].Value = ((tetelArErAnSzerk.anyagDataGridView.CurrentRow.DataBoundItem as DataRowView).Row as<br />
                       Debmut9DataSet.AnyagRow).AnyagBer;<br />
                    egysegar[I] = ((tetelArErAnSzerk.anyagDataGridView.CurrentRow.DataBoundItem as DataRowView).Row as<br />
                       Debmut9DataSet.AnyagRow).AnyagBer;<br />
                    felhasznAnyagSzallitasBindingSource.MoveLast();<br />
                    <br />
                    felhasznaltanyagszallitasDataGridView.Refresh();<br />
                    I++;<br />
                    MessageBox.Show("Added successfully", "Added...", MessageBoxButtons.OK, MessageBoxIcon.Information);<br />
                    return;<br />
                }<br />
            };<br />
tetelArErAnSzerk.Show();<br />
}<br />

AnswerRe: anonymous method runs &quot;too many times&quot; [modified] Pin
Luc Pattyn16-Aug-07 6:45
sitebuilderLuc Pattyn16-Aug-07 6:45 
GeneralRe: anonymous method runs &quot;too many times&quot; Pin
gericooper16-Aug-07 20:26
gericooper16-Aug-07 20:26 
Questionlayers (?) Pin
tim_gunning16-Aug-07 5:52
tim_gunning16-Aug-07 5:52 
AnswerRe: layers (?) Pin
Mark Churchill16-Aug-07 15:54
Mark Churchill16-Aug-07 15:54 
QuestionSelect Method of DataSet - pls help Pin
meeram39516-Aug-07 5:48
meeram39516-Aug-07 5:48 
AnswerRe: Select Method of DataSet - pls help Pin
Giorgi Dalakishvili16-Aug-07 6:02
mentorGiorgi Dalakishvili16-Aug-07 6:02 
AnswerRe: Select Method of DataSet - pls help Pin
kboyette16-Aug-07 10:57
kboyette16-Aug-07 10:57 
QuestionWindows Mobile Applications Pin
Harkamal Singh16-Aug-07 4:57
Harkamal Singh16-Aug-07 4:57 
AnswerRe: Windows Mobile Applications Pin
Not Active16-Aug-07 9:14
mentorNot Active16-Aug-07 9:14 
Question3Gp to MPEG4 convertor [modified] Pin
kibromg16-Aug-07 4:23
kibromg16-Aug-07 4:23 
QuestionExtending frame into client area on Vista using the Aero Basic theme Pin
Scott Dorman16-Aug-07 3:24
professionalScott Dorman16-Aug-07 3:24 
AnswerRe: Extending frame into client area on Vista using the Aero Basic theme Pin
seeitsharper16-Aug-07 23:48
seeitsharper16-Aug-07 23:48 
GeneralRe: Extending frame into client area on Vista using the Aero Basic theme Pin
Scott Dorman17-Aug-07 4:31
professionalScott Dorman17-Aug-07 4:31 
GeneralRe: Extending frame into client area on Vista using the Aero Basic theme Pin
seeitsharper17-Aug-07 5:23
seeitsharper17-Aug-07 5:23 
QuestionHow to retrieve files from "System Volume Information" Folder Pin
ramesh_nrk16-Aug-07 3:13
ramesh_nrk16-Aug-07 3:13 
AnswerRe: How to retrieve files from "System Volume Information" Folder Pin
Martin#16-Aug-07 3:19
Martin#16-Aug-07 3:19 
AnswerRe: How to retrieve files from "System Volume Information" Folder Pin
Luc Pattyn16-Aug-07 4:12
sitebuilderLuc Pattyn16-Aug-07 4:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.