Few problems faced and help needed

Discussion in 'C#' started by nerdy_gal, Dec 2, 2006.

  1. nerdy_gal

    nerdy_gal New Member

    Joined:
    Dec 2, 2006
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    hi all... i am currently doing a school assignment and is facing a few problems. the software i am using for this assignment is visual C# express...
    1) i am having two different forms. and i would like to have the text in the textbox of form 1 to be in form 2 when i close form 1. is there any ways to do it?
    2) i am supposed to print details of an object in the arraylist. the object has a few members data in it... i tried using the codes below... but instead of getting what i want, it keeps giving me the eventid... anyone knows why??
    Code:
     public CalendarEvent GetEvents(string eventid)
            {
                CalendarEvent ce = new CalendarEvent();
                CalendarEvent a = new CalendarEvent();
                
                int t = Convert.ToInt32(eventid);
    
                for (int i = 0; i < EventArrayList.Count; i++)
                {
                    ce = (CalendarEvent)EventArrayList[i];
                    if (t <= EventArrayList.Count)
                    {
                        MessageBox.Show("Please enter a valid event Id");
                    }
                   
                    if (ce.eventid == t)
                    {
                        
                       
                        a.eventid = ce.eventid;
                        a.duration = ce.duration;
                        a.comments = ce.comments;
                        a.category = ce.category;
                        a.title = ce.title;
                        MessageBox.Show(Convert.ToString(a.eventid));
                        MessageBox.Show(Convert.ToString(a.duration));
                    }
                 
                }
                
                return a;
    
    
            }
    3) is it possible for me to have a return statement in the catch block?? if not... may i know how can i catch errors as i do not want to use the if statement to check as i understand too many if statements is not a good idea...

    thanks for your time

    smile,
    nerdy_gal ^^
     
    Last edited: Dec 2, 2006
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Yes its possible in more than one way. Let me know how you are showing the second form.
    Because you are printing them.
    Why do you want the return in the ctch block. have them after the catch block and everything else in the try block.
     
  3. nerdy_gal

    nerdy_gal New Member

    Joined:
    Dec 2, 2006
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    hihi Shabbir... thxs for replying...
    1) the way i show my second form is as follow:

    CalendarMonth1 form = new CalendarMonth1();
    form.Form1 = this;
    form.Show();

    where CalendarMonth1 is my second form which contains the CalendarMonth object.

    2) i don't really get what you mean by i am printing them.

    3) thxs for the idea. this just did not come acoss my mind at all.

    thank you.

    smile,
    nerdy_gal ^__^
     
  4. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Have some custom property which has some get values which you can show in the other form.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice