Click here to Skip to main content
15,892,298 members
Home / Discussions / C#
   

C#

 
AnswerRe: Regular expression to recognise c++ functions in a .cpp file [modified] Pin
Colin Angus Mackay23-Dec-08 0:25
Colin Angus Mackay23-Dec-08 0:25 
GeneralRe: Regular expression to recognise c++ functions in a .cpp file Pin
benjymous23-Dec-08 0:31
benjymous23-Dec-08 0:31 
GeneralRe: Regular expression to recognise c++ functions in a .cpp file Pin
Colin Angus Mackay23-Dec-08 0:33
Colin Angus Mackay23-Dec-08 0:33 
AnswerRe: Regular expression to recognise c++ functions in a .cpp file Pin
User 665823-Dec-08 0:59
User 665823-Dec-08 0:59 
QuestionProblem in usercontrol Pin
SreejithKumar M22-Dec-08 23:44
SreejithKumar M22-Dec-08 23:44 
AnswerRe: Problem in usercontrol Pin
DaveyM6923-Dec-08 0:58
professionalDaveyM6923-Dec-08 0:58 
GeneralRe: Problem in usercontrol Pin
SreejithKumar M23-Dec-08 19:21
SreejithKumar M23-Dec-08 19:21 
GeneralRe: Problem in usercontrol Pin
DaveyM6924-Dec-08 0:21
professionalDaveyM6924-Dec-08 0:21 
Still not exactly sure how you're referencing your user controls and you haven't shown your property getter and setter so it's impossible to determine the cause of your problem.

However, in the spririt of Christmas - here's some working code.
Form1 already has a TabControl (tabControl1) with the default TabPages removed and a Button(button1).
UserControl1 already has a TextBox (textBox1).

I've shown two ways. The first uses an event raised from a UserControl1 instance. The second itterates through all the user controls on all pages.
// Form1.cs
using System;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        TabPage[] pages;
        TabPage page0;
        TabPage page1;
        public Form1()
        {
            InitializeComponent();
            page0 = new TabPage("Page 0");
            // example 1 using event driven method
            UserControl1 userControl1 = new UserControl1();
            page0.Controls.Add(userControl1);
            userControl1.TextDataChanged += new EventHandler(userControl1_TextDataChanged);
            page1 = new TabPage("Page 1");
            page1.Controls.Add(new UserControl1());
            pages = new TabPage[] { page0, page1 };
            tabControl1.TabPages.AddRange(pages);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            MessageBox.Show(GetPagesTextData());
        }

        void userControl1_TextDataChanged(object sender, EventArgs e)
        {
            // Form's caption will change as user control's text box's text changes
            Text = ((UserControl1)sender).TextData;
        }

        public string GetPagesTextData()
        {
            StringBuilder textDatasBuilder = new StringBuilder();
            foreach (TabPage page in tabControl1.TabPages)
            {
                foreach(Control c in page.Controls)
                {
                    if(c is UserControl1)
                        textDatasBuilder.AppendLine(((UserControl1)c).TextData);
                }
            }
            return textDatasBuilder.ToString();
        }
    }
}
// UserControl1.cs
using System;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class UserControl1 : UserControl
    {
        private string textData;
        public event EventHandler TextDataChanged;
        public UserControl1()
        {
            InitializeComponent();
            textBox1.TextChanged += new System.EventHandler(textBox1_TextChanged);
        }

        public string TextData
        {
            get { return textData; }
            set
            {
                if (textData != value)
                {
                    textData = value;
                    OnTextDataChanged(EventArgs.Empty);
                }
            }
        }
        protected virtual void OnTextDataChanged(EventArgs e)
        {
            EventHandler eh = TextDataChanged;
            if (eh != null)
                eh(this, e);
        }
        void textBox1_TextChanged(object sender, System.EventArgs e)
        {
            // USe string builder to build text from other controls too if required
            TextData = ((TextBox)sender).Text;
        }
    }
}


Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)

AnswerRe: Problem in usercontrol Pin
Dragonfly_Lee23-Dec-08 21:46
Dragonfly_Lee23-Dec-08 21:46 
QuestionDataGridView Column no accept tab Pin
Member 197210322-Dec-08 23:15
Member 197210322-Dec-08 23:15 
AnswerRe: DataGridView Column no accept tab Pin
Christian Graus22-Dec-08 23:31
protectorChristian Graus22-Dec-08 23:31 
QuestionPrinting using C++ Pin
Razanust22-Dec-08 23:02
Razanust22-Dec-08 23:02 
AnswerRe: Printing using C++ Pin
Kristian Sixhøj22-Dec-08 23:07
Kristian Sixhøj22-Dec-08 23:07 
AnswerRe: Printing using C++ Pin
benjymous22-Dec-08 23:08
benjymous22-Dec-08 23:08 
AnswerRe: Printing using C++ Pin
N a v a n e e t h22-Dec-08 23:09
N a v a n e e t h22-Dec-08 23:09 
Questiondelegates Pin
sheemap22-Dec-08 22:02
sheemap22-Dec-08 22:02 
AnswerRe: delegates PinPopular
Christian Graus22-Dec-08 22:07
protectorChristian Graus22-Dec-08 22:07 
GeneralRe: delegates Pin
CPallini23-Dec-08 2:05
mveCPallini23-Dec-08 2:05 
AnswerRe: delegates Pin
Brij22-Dec-08 22:38
mentorBrij22-Dec-08 22:38 
AnswerRe: delegates Pin
User 665822-Dec-08 23:13
User 665822-Dec-08 23:13 
Questionc# Pin
sheemap22-Dec-08 21:47
sheemap22-Dec-08 21:47 
AnswerRe: c# Pin
Giorgi Dalakishvili22-Dec-08 21:53
mentorGiorgi Dalakishvili22-Dec-08 21:53 
GeneralRe: c# Pin
sheemap22-Dec-08 21:57
sheemap22-Dec-08 21:57 
GeneralRe: c# Pin
Christian Graus22-Dec-08 22:05
protectorChristian Graus22-Dec-08 22:05 
GeneralRe: c# Pin
CPallini23-Dec-08 2:09
mveCPallini23-Dec-08 2:09 

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.