|
Hi
I have this code
<br />
string name = "tabPage0";
mainTabs.TabPages.Add(name);<br />
Then I would like some way to set tabPage0.Text How is this done?
Thanks
|
|
|
|
|
You could just write a function that will dynamically add new TabPage 's for you. Something like the following will do it for you, this assumes the TabControl is a member of the same class of this method. You could change this if you needed but this should get you started.
private void AddNewTabPage(string tabText)
{
TabPage tp = new TabPage(tabText);
this.TabControl.TabPages.Add(tp);
this.TabControl.SelectedTab = tp;
}
- Nick Parker My Blog | My Articles
|
|
|
|
|
Thanks, I wasn't very clear. I was looking for a way to dynamically name tabs. How could I create a function to add tabs with different names for each one?
|
|
|
|
|
You can use the method I wrote above, write a separate method to randomly generate text and with each text generation, call my method to create the TabPage .
- Nick Parker My Blog | My Articles
|
|
|
|
|
If I'm understanding correctly, what you are trying to acheive cannot be done.
You cannot name a control and then use its name in your code as you would with any other variable. That isnt possible because the compiler will not know of the name ur assigning as it will only be "visible" in runtime.
That means that, follwing ur example:
string name = "tabPage0";
mainTabs.TabPages.Add(name);
You will never be able to use in your code tabPage0.WhateverMethod. That can only be done if u declare a tabPage0 variable in ur code.
U will have to work with the tabpages collection indexes or iterate through it looking for the correct Text/Name or whatever.
|
|
|
|
|
I am trying to draw a Family tree onto a panel by adding several custom panels that contain the data about each person in the tree. I have all the panels displaying but my formula for working out where to place each custom panel is placing them incorrectly.
This is my formula.
child is the custom panel one generation back in the tree and the index is set according to its vertical position in the generation (i.e the one nearest the top of the panel is 1 and the next lowest 2 and then next lowest 3 etc..)
generation is the generation the the animal belongs to (1 being the initial person, 2 being the parents, 3 the grandparens)
pw = the custom panel width, hg = the gap between generations, pd = the custom panel height, paneldepth = the main panel height
I want the tree to draw left to right.
The x co-ordinate works fine its the y co-ordinate that doesnt work, it causes earlier generation to be too close together.
// Set Panel Location
int x = child.Location.X + pw + hg;
int y = ((paneldepth / (generation + 1)) * ((2 * child.Index) - 1)) - (pd / 2);
parentpanel.Location = new Point(x, y);
Can anyone suggest a formula that might work?
|
|
|
|
|
I would like to read unicode from INI in my application. Reading from GetPrivateProfileString is ????
For example..
I want to read and display Thai Words in my application.
[Thai]
Card=บัตร
Thanks in advance.
|
|
|
|
|
You can P/Invoke the GetPrivateProfileString as I did below, string 's in .NET are unicode.
[DllImport("kernel32.dll")]
static extern uint GetPrivateProfileString(string lpAppName, string lpKeyName, string lpDefault, StringBuilder lpReturnedString, uint nSize, string lpFileName);
- Nick Parker My Blog | My Articles
|
|
|
|
|
Hi
Use GetPrivateProfileStringW (notice the W)
That's the unicode version.
|
|
|
|
|
I have a network application. These two application has a form on which two label controls are present.
Please see the diagram...
Host1 Host2
Form1.cs Networkoperation.cs Form1.cs
Networkoperation.cs class actually handles the communication between the two applications.
What I Want? I want to have button on each form If I click the button the text present in a textbox on the form has to go the same label control and should be assigned to the Text property of the control.
I am unable to do this, Because how to get the handle of label control of form1.cs class in networkOperation.cs Class?
Any one who knows it Please help to me.
|
|
|
|
|
Hi!
I'm wondering if there are any free texteditor components out there where you can have syntax hightlighting for multiple languages?
If not, any good articles on how to acomplish this yourself?
Thanks in advance!
~~~~~~~~~~~~~~
Martin Lundberg
Student, Sweden
I have to thank every member of the Code Project for making it such a great place for a beginner to learn!
|
|
|
|
|
Martin Lundberg wrote:
If not, any good articles on how to acomplish this yourself?
There are articles online that cover how to do this using a RichTextBox class. This[^] one should get you started.
- Nick Parker My Blog | My Articles
|
|
|
|
|
|
Hi,
I want to select a member of TabControl by stroking keyboard but not by clicking the mouse on it.So,I think I have to create a shortcut key for that member.Can you tell me how to create it?
Thanks!
|
|
|
|
|
i'm not certain what you mean. but if i understandyou properly you want a control to gain focus when a button is pressed?
well i havn't done anything with tabs (never needed to) but here's the general code.
goto the events list on the form that the tabs are on and create a KeyDown handler by double clicking on it.
in the handler do something like this...
if(e.KeyCode == Keys.____)
{
tc.focus();
}
e being keyeventargs, tc being your tab control.
i hope that helped a bit
|
|
|
|
|
Here[^] is an article on creating keyboard accelerators in C#. This should get you started.
- Nick Parker My Blog | My Articles
|
|
|
|
|
After this code EndofHeader is still zero.
Why?
FİleInfo fp = new FileInfo(path);
FileStream file = fp.Open(FileMode.Create);
StreamWriter sw = new StreamWriter(file);
sw.WriteLine("{0} {1} {2} {3} {4} {5}",m,0,-1,1,1;
EndofHeader = file.Position;
balkan
|
|
|
|
|
You could try
sw.WriteLine(String.Format("{0} {1} {2} {3} {4} {5}",m,0,-1,1,1,1));
one argument is missing, and String.Format too...
try adding sw.Flush(); after WriteLine
Hope it'll help...
Robin Panther
|
|
|
|
|
i need some help in validating the contents in property grid in c#.
if anyone knows about this kindly answer the question.
sundar
writesundar@yahoo.com
|
|
|
|
|
hello i want to trap enter/return keystrokes in my custome control no matter wich control withint the custom control has focus i basicly want my control to have an ok button that always reacts to the enter key how do i make this happen?
|
|
|
|
|
your custom control needs to have a keydown handler.
if possible make it extend the Form class, then you can just set the AcceptButton.
|
|
|
|
|
i guess my main problem is is that a my control uses a text box thats not multiline i can trap the enter keystrokes but it beeps every time i have it set to accepts return but since its not multiline it beeps how can i get around this without making it multiline
|
|
|
|
|
i don't understand what you're saying. could you explain exactly what you're doing? if you have a regular single line text box, it will always beep for return strokes unless you use a keyboard hook that intercepts the enter keystroke but that's icky.
From what i understand you might HAVE to use keyboard hooks though. the additional problem is that you don't want the keyboard hook to trap EVERY enter keystroke (per se if you're in another app). to solve this you have to run the hook, when WndProc is called you have to check if your control has focus. if it doesnt you have to pass the message on to the next window handle in the chain to recieve the message. If your control has focus you do whatever you want it to do and don't pass on the message.
|
|
|
|
|
i have a control with a text box and a button and when the user hits enter in the text box im making it trigger the button click event but it always beeps :P
|
|
|
|
|
allright. so lets take a look at it as a timeline.
-You click on the textbox.
-you type something
-press enter. ->
-the KeyPressed message gets sent to a list of handles ending in the text box.
-text box recieves it, it's not multiline so it error-beeps.
your goal is to intercept the message, handle it yourself, and stop it from being passed.
do you need some help writing a global hotkey / keyboard hook?
|
|
|
|