Page 2 of 2 FirstFirst 12
Results 11 to 14 of 14
  1. #11

    Quote Originally Posted by Sorry View Post
    ingon ani xa bro..
    naa koy combo box sa main form, kung mo select na gani ko ug item gikan sa combo box,
    mo appear dayon ang sub form, so adto nako mag input sa mga info., unya, kung mo click nako
    sa button nga display nga naa sa sub form adto xa ma display sa listbox nga naa sa main form.

    sakto ba?
    basta ingon ana xa..
    ... Hi sorry, by the way, Im a newbie here in istorya..
    Im working as a developer, in an IT company here in Cebu, no need to mention the comp, it wont matter man sad..

    according to your post, you have a parent Form, then this form will load another form, then you would want to reflect the changes you made in the sub form to the parent Form.. I wont give you codes its for you to make, and trust me you'll enjoy coding it (learning).

    lets call the first form or the calling Form the Main Form, and the form that will load the Sub Form.
    So we have 2 forms the Main Form and the Sub Form. SubForm will only load when an event in the main form occurs. Like you said, a combo box, when you select items in the combo box the SubForm appears.

    Now this means that the SubForm is only an object that is part of the MainForm. Now have you ever heard of event handling in .Net?, its easy in vb.net, but its complicated in C#. To give you an introduction to event handling, and to make it simple, ani lang, when you click a button, that is considered and event, ang event is Click.. now you might not notice naa na syay event handler which is pointing to a method, usually if your new to .net d nmo makita na nga code coz its on the designer partial class... labi na sa C#, in VB it is easy to identify if ang method ni handle og event, notice sa kilid sa method naay keyword nga Handles ObjectName.EventName..

    Now in C#, as i said event handling is a bit complicated, you have to know what are delegates first, then create an object of delegate type then invoke that delegate. Its getting complicated, dli madala og suwat, ani nlang ang concept..

    Your SubForm should have an event, this event will be handled by the MainForm, so when that event is raised by the SubForm, the MainForm will handle it and will know what to do with it, pero libog jud sya sa.. Dli jud madala og discuss if e type ra..

    I can send you a sample code anyway.. please shoot me an email.. MDCuesta@interprisesolutions.com if naay kai pangutana, then ill send you the code.

    PS: Asa ka nag skol dong?

  2. #12
    Why not create a class that you could populate value from sub form and access it in your main form?

    something like this.
    Code:
    class Program{
    	static void Main(){
    		forListbox fl = new forListbox();
    		Class1 c = new Class1(fl);	
    		Console.WriteLine(fl.Name);
    		Console.WriteLine(fl.Address);
    	}
    }
    	
    	
    class Class1{		
    	public Class1(){}
    		
    	public Class1(forListbox fl){			
    		Console.WriteLine("calling from main form");			
    		fl.Name = "none";
    		fl.Address = "cebu city";
    	}		
    }	
    
    public class forListbox{
    	string name;
    	string address;
    	
    	public string Name{
    		get{return this.name;}
    		set{this.name  = value;}			
    	}
    	
    	public string Address{
    		get{return this.address;}
    		set{this.address = value;}				
    	}
    }
    Well you could use events/delegates in solving your problem as what fixyourself suggested.

  3. #13
    How about mag-create ka ug interface?

  4. #14
    Quote Originally Posted by ta3 View Post
    Why not create a class that you could populate value from sub form and access it in your main form?

    something like this.
    Code:
    class Program{
    	static void Main(){
    		forListbox fl = new forListbox();
    		Class1 c = new Class1(fl);	
    		Console.WriteLine(fl.Name);
    		Console.WriteLine(fl.Address);
    	}
    }
    	
    	
    class Class1{		
    	public Class1(){}
    		
    	public Class1(forListbox fl){			
    		Console.WriteLine("calling from main form");			
    		fl.Name = "none";
    		fl.Address = "cebu city";
    	}		
    }	
    
    public class forListbox{
    	string name;
    	string address;
    	
    	public string Name{
    		get{return this.name;}
    		set{this.name  = value;}			
    	}
    	
    	public string Address{
    		get{return this.address;}
    		set{this.address = value;}				
    	}
    }
    Well you could use events/delegates in solving your problem as what fixyourself suggested.



    ----------

    thing is if you would create a class/object to be populated on the sub form, you have to wait till the subform to be unloaded, for the changes to reflect..



    based on the example

    forListbox fl = new forListbox(); //fl is an object type of forListBox
    Class1 c = new Class1(fl); //c is an object type of Class1 which asks for a
    // parameter of type forListBox
    // note that objects are automatically passed by ref
    //so whatever happened to f1 in the object c (Class1)
    //should also reflect in the class where f1 is declared.
    Console.WriteLine(fl.Name);
    Console.WriteLine(fl.Address);
    ----------------

    now if you would using events/delegates... it wuold be so easy then changes would reflect automatically to the main form, then you could still do other stuffs in the sub form..

    thanks

  5.    Advertisement

Page 2 of 2 FirstFirst 12

Similar Threads

 
  1. Replies: 1329
    Last Post: 05-11-2024, 12:34 PM
  2. asp.net c# newbie..pls help..
    By shawn87chau in forum Programming
    Replies: 15
    Last Post: 11-26-2008, 10:44 AM
  3. NEWBIE here...Kung nid nyo Windows Mobile APPS just PM me...
    By maverick_007 in forum Gizmos & Gadgets (Old)
    Replies: 0
    Last Post: 11-14-2008, 09:39 PM
  4. hi guyz .. nid elp about notepad++
    By Sorry in forum Programming
    Replies: 13
    Last Post: 10-15-2008, 09:45 PM
  5. bro. i nid a lil elp...
    By deathrow in forum Websites & Multimedia
    Replies: 12
    Last Post: 02-25-2008, 06:39 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
about us
We are the first Cebu Online Media.

iSTORYA.NET is Cebu's Biggest, Southern Philippines' Most Active, and the Philippines' Strongest Online Community!
follow us
#top