4 Replies - 337 Views - Last Post: 06 February 2013 - 02:39 PM Rate Topic: -----

#1 teyrebaz  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 19
  • Joined: 14-January 12

Second form item_check event problem.

Posted 06 February 2013 - 01:40 PM

Hello all,
I have two forms.On first form i am listing rooms and second form is for editing room. I am passing Room object from first form to second form. But before second form unload the secondForm Checkboxlist itemcheck event occurs.

I used boolean var with if statement for solving it but i have two checkboxlist, it was occured again at the second checkboxlist.
How can i stop it?
Thanks.
Is This A Good Question/Topic? 0
  • +

Replies To: Second form item_check event problem.

#2 Michael26  Icon User is offline

  • DIC-head, major DIC-head
  • member icon

Reputation: 359
  • View blog
  • Posts: 1,529
  • Joined: 08-April 09

Re: Second form item_check event problem.

Posted 06 February 2013 - 01:49 PM

Do you know that C# is event based language
Here is the glimpse on that, and also check MSDN for that
Was This Post Helpful? 0
  • +
  • -

#3 teyrebaz  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 19
  • Joined: 14-January 12

Re: Second form item_check event problem.

Posted 06 February 2013 - 02:01 PM

View PostMichael26, on 06 February 2013 - 01:49 PM, said:

Do you know that C# is event based language
Here is the glimpse on that, and also check MSDN for that

Yes, i know Micheal but i dont know why it occured at after second form constructor complete. thanks.
Was This Post Helpful? 0
  • +
  • -

#4 Michael26  Icon User is offline

  • DIC-head, major DIC-head
  • member icon

Reputation: 359
  • View blog
  • Posts: 1,529
  • Joined: 08-April 09

Re: Second form item_check event problem.

Posted 06 February 2013 - 02:05 PM

Well without that code here, i can only guess :)

Quote

But before second form unload the secondForm Checkboxlist itemcheck event occurs.

I would double check that part.

This post has been edited by Michael26: 06 February 2013 - 02:07 PM

Was This Post Helpful? 0
  • +
  • -

#5 teyrebaz  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 19
  • Joined: 14-January 12

Re: Second form item_check event problem.

Posted 06 February 2013 - 02:39 PM

View PostMichael26, on 06 February 2013 - 02:05 PM, said:

Well without that code here, i can only guess :)/>/>/>

Quote

But before second form unload the secondForm Checkboxlist itemcheck event occurs.

I would double check that part.

Error occurs from second forms method when i call it at constructor. I have a method for checkboxlist which is handling some items checkstate unchecked to checked. How can i prevent it or can i stop execution of checkboxlist itemcheck event at the secondform's constructor?
//second form's state alter method.. calling at constructor.
 void SelectedRoomBedTypes()
        {
            foreach (var item in bedtypes)
            {
                for (int i = 0; i < clstBedTypes.Items.Count; i++)
                {
                    BedTypes bt = clstBedTypes.Items[i] as BedTypes;
                    if (bt.ID == item.BedTypeID)
                    {
                        clstBedTypes.SetItemChecked(i, true);
                    }
                }
            }
        }


//clstBedTypes ItemCheck event


            BedTypes bt = (BedTypes )clstBedTypes.SelectedItem;
            if (e.NewValue == CheckState.Unchecked)
            {
                RoomBedType r = new RoomBedType();
                r.RoomID = _room.ID;//_room object from first form
                o.BedTypeID = bt.ID;
                MessageBox.Show(YatakTipIslemleri.OdayaGoreYatakTipSil(o));

            }
            else
            {
                OdaYatakTip o = new OdaYatakTip();
                o.OdaID = _oda.ID;
                o.YatakTipID = yt.ID;
                MessageBox.Show(BedTypeProc.SaveBedRoomTypeByRoom(o));
            }


thanks.

Error occurs from second forms method when i call it at constructor. I have a method for checkboxlist which is handling some items checkstate unchecked to checked. How can i prevent it or can i stop execution of checkboxlist itemcheck event at the secondform's constructor?

//second form's state alter method.. calling at constructor.
void SelectedRoomBedTypes()
{
foreach (var item in bedtypes)
{
for (int i = 0; i < clstBedTypes.Items.Count; i++)
{
BedTypes bt = clstBedTypes.Items[i] as BedTypes;
if (bt.ID == item.BedTypeID)
{
clstBedTypes.SetItemChecked(i, true);
}
}
}
}



//clstBedTypes ItemCheck event

BedTypes bt = (BedTypes )clstBedTypes.SelectedItem;
if (e.NewValue == CheckState.Unchecked)
{
RoomBedType r = new RoomBedType();
r.RoomID = _room.ID;//_room object from first form
r.BedTypeID = bt.ID;
MessageBox.Show(YatakTipIslemleri.OdayaGoreYatakTipSil(o));

}
else
{
RoomBedType r = new RoomBedType ();
r.OdaID = _oda.ID;
r.YatakTipID = yt.ID;
MessageBox.Show(BedTypeProc.SaveBedRoomTypeByRoom(o));
}


thanks.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1