|
This one does work for the test case, you may need to extend it for other classes etc.:
MyClass::.+\)(\r?\n?)*{
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
hai
In my application,I dynamically created tabpages in my winform.
ie i have a button"Add new tab"
when i click on that button ,
a new tabpage is created.
but that tabpage is a usercontrol.
when i clicking again and again same usercontrol is regenerated as tabpage
but the problem is when i am calling properies(which i am created in userctrl.cs page) i ve to retrieve values of controls(txtbox,ddl...) present in usercontrol according to tabcount
ie if tabcount is 1,i need value of controls present in userctrl of tabpage1,then same of tabpage2
I used a for loop
userctrl uctr;
class obj;
for(i=0;i<intTabcount;i++)
{
obj.data=uctr.txtData;// data is proprty of class class
------//txtData is proprty of usrctrl
------
}
but i am getting "" as value
pls help me to solve pblm
|
|
|
|
|
What are you adding your user controls to and how?
Normally, you'd use a TabControl. That has a TabPages property of type TabPageCollection. To retrieve data from a particular page you use that page's index. To get all of them you'd use a foreach or a for loop like yours and an index of i for to get the individual page.
StringBuilder allTextBuilder = new StringBuilder();
foreach (TabPage item in tabControl1.TabPages)
{
allTextBuilder.AppendLine(item.Text);
}
string allText = allTextBuilder.ToString();
StringBuilder allTextBuilder2 = new StringBuilder();
for (int i = 0; i < tabControl1.TabPages.Count; i++)
{
allTextBuilder2.AppendLine(tabControl1.TabPages[i].Text);
}
string allText2 = allTextBuilder2.ToString();
string tabPageText = tabControl1.TabPages[0].Text;
DaveBTW, 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)
|
|
|
|
|
my usercontol contains textboxes,datagridview and another usercontrol.I placed it statically.
I am using multitier architecture.
I created get and set property of controls of usercontrols in its codebehind page. Problem while looping through each tab i am not getting values enterd in textbox.Only thing i am getting is "" value
|
|
|
|
|
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 TabPage s 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.
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");
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)
{
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();
}
}
}
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)
{
TextData = ((TextBox)sender).Text;
}
}
}
DaveBTW, 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)
|
|
|
|
|
sendtosreejith wrote: userctrl uctr;
class obj;
How can you get the usercontrol on the tabpage? You cannot get the value from the control if you just declared it. BTW, if you can obtain the custom usercontrol in a proper way, you will get the correct value. I have tried this simply in my code. Such as:
for (int i = 0; i < this.tabControl1.TabPages.Count; i++ )
{
UserControl1 u = this.tabControl1.TabPages[i].Controls[0] as UserControl1;
Console.WriteLine(u.Text);
}
Hope this can help you.
LuckyBoy
|
|
|
|
|
how to
DataGridView Column no accept tab?
|
|
|
|
|
I don't know. What the hell does this mean ?
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
My question is can we use C++ or Code blocks to print the output on a paper. I got the following code. Does this prints on a paper.
#include <fstream>
#include <iostream>
using namespace std;
int main()
{
ofstream printer( "prn" );
if (!printer)
{
cout << "fooey!\n";
return 1;
}
printer << "Hello world!\n";
printer.close();
return 0;
}
|
|
|
|
|
This is the C# forum.
You wanna ask your question in the C++ forum.
Kristian Sixhoej
|
|
|
|
|
You should probably ask in the c++ forum!
(If you've got code, why not try it?)
|
|
|
|
|
Razanust wrote: I got the following code. Does this prints on a paper.
NO.
Razanust wrote: My question is can we use C++ or Code blocks to print the output on a paper.
Yes. But you are in wrong forum. Try C++/MFC board.
|
|
|
|
|
please give me details description of Delegate
how where any we use this word....
rizvan sivally
|
|
|
|
|
A delegate is a reference to a function. All events are delegates.
Stop reading magazines on the toilet and thinking you can post some buzzwords here and become a programmer. Buy a book, work through it, ask questions here when you have at least some basic idea, these forums are to help programmers who are stuck, not to help people who are incapable of buying a book, or using google.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Welcome in the CP's Memorable Quotes page [^], Christian.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Check the links
[^]"> [^]">
Cheers!!
Brij
|
|
|
|
|
|
please expalin me in details object,class,method....
due to i am little bit in problem to how i use method,object and class.
rizvan sivally
|
|
|
|
|
sheemap wrote: i am little bit in problem
No, you are having big problems.
First of all read this[^]. Then buy a c# book for beginner and start reading it.
|
|
|
|
|
Yes I have 1 yaer experience
but till now i am not more confidet on these 3 word.so can u give me details description to any one can get def.because i wanted to know what u r giving definition............
yes this is big problem
any one can help me
rizvan sivally
|
|
|
|
|
sheemap wrote: Yes I have 1 yaer experience
I don't see how that is possible.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
He has indeed 1 year of experience in botanics.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
sheemap wrote: Yes I have 1 yaer experience
If this were true you would know the answer to your question yourself.
Do some reading/research (you ever heard of google????)
|
|
|
|
|
1 year's experience of what?
Let's see. Here's a snippet. It contains your answers. If you've got programming experience, but are just getting confused by the terminology, it should point you in the right direction. If you're still confused, I'd go with my previous statement of getting yourself a good book on Object Oriented Programming, as it'll likely cover those in the first chapter.
class MyClass
{
public void DoSomething()
{
Bitmap myBitmap = new Bitmap();
}
};
|
|
|
|
|
what relation in function and method
rizvan sivally
|
|
|
|