|
[EDIT]I'm just come up on a much bigger problem, that I'm not sure how I missed and maybe you could help me with it. It appears that the UserControl isn't being added to the TabControl. Here's my code for that, which I assume will fix my other problem since I'll now be able to actually see the control. PdsContainer is the TabControl and PdsPage is my UserControl
PdsPage testPage = new PdsPage (DateTime.Now);
PdsContainer.TabPages.Add ("Page1", testPage.Title);
PdsContainer.TabPages[0].Controls.Add (testPage);
Alright. I threw my bad idea out the window, took your good advice and implemented my drawing in the OnPaint handler, but I'm still not getting anything to draw on the window. Here's the code so maybe you could point out what I'm doing wrong.
Pen greenPen = new Pen (Color.GreenYellow, 5);
Point point1 = new Point (16, 129);
Point point2 = new Point (333, 129);
e.Graphics.DrawLine (greenPen, point1, point2);
Refresh (); I tried it with and without that Refresh cause I wasn't sure if I needed it. This code is in the OnPaint handler of a UserControl that is added to a TabControl at runtime in case that helps.
Thanks for the help.
- Aaron
-- modified at 21:04 Sunday 11th December, 2005
|
|
|
|
|
You don't need the Refresh.
You should put the pen in a using statement so it gets cleaned up, this code is leaking resources.
using (Pen greenPen = new Pen....)
{
// rest of the code in here
}
If you wanted a pen 1 pixel wide, Pens.GreenYellow is a better choice again ( although not in this case ).
Have you put a breakpoint in this code to make sure it's called, and checked that your control is 130 pixels wide on the form ? Because I don't see why this shouldn't work.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I actually just edited my last post, which may explain why it's not working. The UserControl isn't being added to the TabControl. If possible could you take a look at my previous post which contains the code I'm using to add the UserControl to the TabControl
Thanks so much for the help.
- Aaron
|
|
|
|
|
Have you checked the location, size, name and visible properties of this control ? Perhaps they need to be set in order for this control to appear on the form ? i.e. perhaps it's there but not visible, or not in the visible area.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I have testPage.Anchor = (AnchorStyles.Left | AnchorStyles.Top); and testPage.Visible = true; properties set, but it's still not showing anything on the TabPage.
Any ideas?
Thanks.
- Aaron
|
|
|
|
|
Not off the top of my head. Have you checked that the control is in the controls collection, and what it's properties are ? What if you add the control to the tab page manually, or add it to another form ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I just did a test to see if the control was being added to the TabPage controls collection, but it doesn't appear as though it's being added because the returned controls collection is empty. Here's all the code I'm using (it's in the OnLoad event of my Form, I don't know if that makes a difference)
private void PdsPad_Load (object sender, EventArgs e)
{
PdsPage testPage = new PdsPage (DateTime.Now);
testPage.Anchor = (AnchorStyles.Left | AnchorStyles.Top);
testPage.Visible = true;
PdsContainer.TabPages.Add ("Page1", testPage.Title);
PdsContainer.TabPages[0].Controls.Add (testPage);
Control[] ctrls = PdsContainer.TabPages[0].Controls.Find ("PdsPage", true);
foreach (Control ctrl in ctrls)
{
MessageBox.Show (ctrl.ToString ());
}
Form testForm = new Form ();
testForm.Controls.Add (testPage);
testForm.Show ();
} It's not being added to the testForm either. Do you see anything that's amiss?
Thanks for taking the time to help me on this.
- Aaron
|
|
|
|
|
monrobot13 wrote: Control[] ctrls = PdsContainer.TabPages[0].Controls.Find ("PdsPage", true);
What if you drop the 'find' ? I reckon this won't work because the name of your control isn't set.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Christian Graus wrote: What if you drop the 'find' ?
That worked and the MessageBox now displays PdsPad.PdsPage so it's getting added to the TabPage's control collection. I also thought the problem might be that I was declaring the PdsPage inside the OnLoad handler so when it returned it was going out of scope, but I moved it into the class as a member variable and it still doesn't show anything. Any ideas?
I appreciate all this help you're giving me.
- Aaron
-- modified at 21:45 Sunday 11th December, 2005
|
|
|
|
|
You don't need the member variable, it's kept in scope because it's part of a collection that is in scope.
Once you can see it in the collection, check it's position and it's size ( and double check that it's still visible ). If that doesn't help, I'm not sure.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
First, thanks very much for all your help on the issue.
Second, I finally figured out the problem and it's basically that I'm an idiot. I added a couple of extra constructors to the UserControl, but in my infinite stupidity forgot to add the InitializeComponent method to them so none of the controls were actually being created and initialized.
Again, thanks for all your help, if I hadn't been able to confirm (through your help) that the control was actually being added to the TabPage, I would have taken a much longer time to go back and check the UserControl code instead of the code I was using to add it.
Thanks muchly.
- Aaron
|
|
|
|
|
No worries, glad to help.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi..
Can CE.Net 4.2 support compact framework 2.0
Can I use Visual Studio 2005 C# to develop and windows CE 4.2 Application..
Because the pda that the customer using is installed with Win CE 4.2
I Want to do and small application where they can keyin some info and later upload to ftp serrer from the PDA using dial up modem in PDA
what is the best solution for me
thanks.
|
|
|
|
|
Hi guys,
I face the folloing problem and i hope you can help me:
I want to play mp3s on Pocket PC.
I got some src in C++ I recompile them using eVC 4 and tried to access the API to make my app work.
I can't solve the following issues:
1) I make a class to import my DLLs but the CallingConvention has only Winapi option to choose and not Cdecl.
2) The src in C++ is very but written (no comments) and i can't understand what arguments are for.
So,
Does anyone have anything in mind that can help? I read all the articles concerning mp3 but I still can make my App work.
Any link or any tutorial that can help?
Thanks for your time!
Parispo9
|
|
|
|
|
Hello,
If I have a class that does some calculations and I want to show the result of those calculations on a form's textbox, how can I do that ?
I have tried writing the following on the class, but it doesn't work:
form1.textbox1.text = showData(initialValues);
Where show data is one of the class' methods and it returns a string.
form1 also shows some other data that doesn't have anything to do with the method showData. showData is invoked by pressing a button on form1.
Thanks.
Regards,
Carlos
|
|
|
|
|
Carlos,
Do you have your capitalization correct? Perhaps it should read:
form1.textBox1.Text = showData( initialValues ); ?
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
There is table with name TableName in first dataset
Id Name Selected
----------------------
1000 Name1 0
1001 Name2 0
1002 Name3 0
There is table with the same name in second dataset
Id Name Selected
----------------------
1000 Name1 1
How can I merge them to get this:
Id Name Selected
----------------------
1000 Name1 1
1001 Name2 0
1002 Name3 0
I prefer to do this by using Merge method, but not with foreach...
|
|
|
|
|
Where do you get the datasets from? If you fetch them from a database, you can easily merge them in the query. Example:
select Id, Name, Selected from Table1
union
select Id, Name, Selected from Table2
order by Id
---
b { font-weight: normal; }
|
|
|
|
|
u can try to use the ADO dataset merge functin [URDATASET].Merge([URANOTHER DATASET]
i may work and works for me last time
|
|
|
|
|
Merge will only merge tables into the dataset not the actual table.
Calling ImportRow on the target table will do what you want.
You much better off to put this action into a stored procedure get the result into a table.
Your trying to do a set method in an ISAM structure. It wont work.
I'm not an expert yet, but I play one at work. Yeah and here too.
-- modified at 20:16 Sunday 11th December, 2005
|
|
|
|
|
plz
i need to know how to represent (retrieve) the DOM tree of HTML document using C#
please Uegently
|
|
|
|
|
Use Microsoft.mshtml.dll, you can retrieve the DOM tree as mshtml.IHTMLDocument2
Optionally, if you're using .NET 2.0, you can use the System.Windows.Forms.WebBrowser to load an HTML document, then return the DOM tree using System.Windows.Forms.WebBrowser.Document.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Bought a House!
Judah Himango
|
|
|
|
|
want to access to activeownedform and also arranging my ownedforms.
In fact i want some forms that ,can access to number of that from the array(this.ownedforms.lenght)and this forms can open in the outside of parent(owner) not like MDI and can do all things that i explained.
parastoo ask you?
-- modified at 7:39 Sunday 11th December, 2005
|
|
|
|
|
To open a new window, using form.ShowDialog()
You can create a Form[] and add eached launched form to that array, sure. Or, use System.Collections.Generic.List<Form> if you want the list to grow as necessary.
If I'm not understanding your problem, you'll need to write your English clearer, as it is difficult to understand.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Bought a House!
Judah Himango
|
|
|
|
|
Hi all,
How can i use system.license library to validate my product license, and what is the standard form for license generator
Thanks
|
|
|
|