|
My name is gal edvi .... what about my question? anyone know such component?
|
|
|
|
|
Do you mean edit the text that is displayed?
this.tabControl1.TabPages[0].Text="whatever you want";
--EricDV Sig---------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters
|
|
|
|
|
sorry ... mabye i wasn't clear ... i want that the user will be able at runtime change the tab page name while the software is running ...
thanks
|
|
|
|
|
Just put a textbox on your form and put this code behind a button Click event:
this.tabControl1.TabPages[0].Name = this.textBox1.Text; This will change the first page's name.
--EricDV Sig---------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters
|
|
|
|
|
Well, I am using Visual C# 2005 express, and I am looking to start making a nice shiny program. My question now is, on a windows Form, how can I write code behind a button so that when it is compiled and run, a new, and completely functional new button can be formed?
http://img102.imageshack.us/img102/8792/randomng3.jpg
So basically, disregarding the captions I put on the buttons, how on demand of a click, can I make an exact copy of the button clicked, 5 or however many pixels to the left (or right, or above, whatever)?
|
|
|
|
|
Do exactly what the IDE is doing for you when you place a button on a form at design time
Take those pieces of code and replicate them when you need.
SkyWalker
|
|
|
|
|
Mircea Puiu wrote: Take those pieces of code and replicate them when you need.
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
this.button1.Location = new System.Drawing.Point(62, 54);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 0;
this.button1.Text = "button1";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
}
private System.Windows.Forms.Button button1;
Ok, with some editting there is all the information regarding button1, so I have tried copying and pasting all and parts of the code into any place that makes sense, and either it tells me
"Type or namespace, or end of file expected", or it compiles and nothing happens upon button click. So then I change all the places where it says button1 to button2, and of course it tells me "We don't have a definition for button2"...
Can anyone spare the time to be a bit more specific 
|
|
|
|
|
If you SuspendLayout and do not ResumeLayout , then nothing will seem to happen
SkyWalker
|
|
|
|
|
Suppose you have
private System.Windows.Forms.Button TheNewButton;
Somewhere, you want to have a piece of code creating a new button. Here the code you need:
this.SuspendLayout();
TheNewButton = new Button();
this.TheNewButton.TextAlign = ContentAlignment.MiddleCenter;
this.TheNewButton.Width = 140;
this.TheNewButton.Height = 40;
this.TheNewButton.Text = "New button";
this.TheNewButton.UseVisualStyleBackColor = true;
this.TheNewButton.Visible = true;
this.TheNewButton.Location = new System.Drawing.Point(150, 24);
this.Controls.Add(TheNewButton);
this.TheNewButton.Click += new System.EventHandler(this.TheNewButton_Click);
this.ResumeLayout();
this.Refresh();
Then do not forget to add the TheNewButton_Click() to your form class:
private void TheNewButton_Click(object sender, EventArgs e)
{
}
SkyWalker
|
|
|
|
|
private void button1_Click(object sender, EventArgs e)
{
Button buttonNew = new Button();
buttonNew.Location = new Point(button1.Left + button1.Width +25, button1.Top );
buttonNew.Name = "buttonNew";
buttonNew.Size = new Size(130, 26);
buttonNew.Text = "buttonNew";
buttonNew.Click += delegate(System.Object o, EventArgs eArgs)
{ MessageBox.Show("new button clicked"); };
this.Controls.Add(buttonNew);
}
--EricDV Sig---------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters
|
|
|
|
|
I'm writing label-like control but not inheriting from anything.
And so I'm trying to add mouse events like MouseClick..
I read somewhere to put:
public delegate void MouseEventHandler(object source, int clickCount);
public event MouseEventHandler MouseClick;
public void OnMouseClick(object source, int clickCount) {
MessageBox.Show("clicked");
}
but thad doesn't seem to work..
I tried searching for it but all i found was inherited controls overriding these events..
life is study!!!
|
|
|
|
|
not registering events means not capturing events
SkyWalker
|
|
|
|
|
hello;
i want to catch that user double clicks on filled cells on datagrid but there is no event for this, is there any idea for handle it!
thanks
|
|
|
|
|
And one datagrid there is a cellcontentdoubleclick event but on other datagird doesnt exist.
On second datagrid i have initilazed datacolumns manually from properties. is that problem
|
|
|
|
|
If I remember correctly, the double click is actually broken down into 2 clicks: a click for the datagrid and another one for the datagrid cell. To achieve what you want, you either use a context menu (allowing the user to do multiple things, among them the action required by your double click), or you extend the datagrid class and try to capture the double click event.
SkyWalker
|
|
|
|
|
hi thanks for your reply
my problem is, datagrid doesnt have cellcontentdoubleclick but datagridview has cellcontentdoubleclick. and i have to use datagrid. beucase i wrote 6,7 pages code i cannot change
Now how can i use context menu i didnt use it before
thanks
best regards
|
|
|
|
|
|
thanks
it is so usefull
|
|
|
|
|
In visual c++ the keys ctrl-f2 puts a little blue bookmark next to the current line of code. To return to this code a person just uses the f2 key.
How can I book mark code in the .net editor?
thanks;)
|
|
|
|
|
See Tools -> Customize -> Commands -> Edit
SkyWalker
|
|
|
|
|
|
Ctrl+K. BTW - this is not the right forum for this question. This should have been asked in the Visual Studio forum.
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi All
I'm new to C# multithreading and timers.
I've got the code below where I want to prevent the time from repeting itself when the argument passed is not of the string type.
If I uncomment Thread.Sleep(Timeout.Infinite) doesn't work and keeps writing to the console each second when I expected to be stopped.
Why it happens?
Do I have to call tmr.Change(Timeout.Infinit,0) from TimerMethod? This way tmr variable should be shared between the main thread and the thread for the timer and syncrhonization/locking should be involved. Does exist some function to call from TimerMethod from stop itself without referring the Timer object tmr?
Regards
manuStone
class TestTimers
{
public static void TimerMethod(object obj){
if (obj is string) {
String str = (String)obj;
Console.WriteLine(String.Format("Timer by at {0:N6} by {1}", _tmr_cnt, str));
Interlocked.Increment(ref _tmr_cnt);
}
else {
Console.WriteLine("Passed Wrong Argument");
//How to stop the timer here?
//Thread.Sleep(Timeout.Infinite); Doesn't work:why?
//Do I have to call tmr.Change(Timeout.Infinit,0) here?
}
}
public void CallToThread(){
tmr_clbck = new TimerCallback( ThreadFoos.TimerMethod );
tmr = new Timer(tmr_clbck, 5, 0, 1000);
}
private Timer tmr = null;
private TimerCallback tmr_clbck = null;
}
|
|
|
|
|
|
Thanks
I will start digging on it.
Regards
ManuStone
|
|
|
|