|
I have the following problem
-I created a form with an tab control
-I the tab control contains (minimum) 2 tab pages
-In the second (non selected) tab page i have a control
-And there is another formular (irrelevant content)
<br />
#region PREPERATION<br />
Form f = new Form();<br />
TabControl t = new TabControl();<br />
<br />
TabPage tp1 = new TabPage("page1");<br />
TabPage tp2 = new TabPage("page2");<br />
<br />
Button b = new Button();<br />
b.Size = new Size(100, 20);<br />
<br />
tp2.Controls.Add(b);<br />
<br />
t.TabPages.Add(tp1);<br />
t.TabPages.Add(tp2);<br />
<br />
this.Controls.Add(t);<br />
t.BringToFront();<br />
#endregion PREPERATION<br />
When i first open the child-form with Show() and then select the tab page with the control the parent-form is focused again.
f.Show();<br />
t.SelectedIndex = 1;
How can i force the child-form to keep its focus, while the parent change the tab page?
I don't want to use ShowDialog() or Show(this).
Is this a bug or a feature of the tab control (tab page)?
(Is the only way to fix it, changing the order of the source code?)
|
|
|
|
|
Try tp2.Select(); You don't want to select the tab control, but the actual tab with the control on it.
Hogan
|
|
|
|
|
It does not work.
It don't show the tab page (tp2).
|
|
|
|
|
Does anyone have another idea?
|
|
|
|
|
Hi
Can anyone tell me how to generate a date in random in the interval of two dates (Max date and the Min date)...
Please anyone suggest the answer soon as my due date is nearing
Thx
Anjum
|
|
|
|
|
search on google for "c# random" it'll tell you about the random class ... the random class takes a min int and a max int ... the rest you just need to code.
|
|
|
|
|
I think you can do that with Random Class and DateTime Struct
you can get number of available days in each month with DateTime.DaysInMonth method for correct random date generating and then simply put your generated random numbers from random class in the Constructor of DateTime struct and you will have it.
|
|
|
|
|
1) Calculate the number of days between MIN & MAX.
2) Get random number within that range.
3) Add the random number to MIN.
TimeSpan ts = DateTime.Parse("12/31/2006") - DateTime.Parse("1/1/2006");
Random r = new Random();
int randomDays = r.Next(ts.Days + 1);
DateTime randomDate = DateTime.Parse("1/1/2006").AddDays(randomDays);
MessageBox.Show(randomDate.ToShortDateString());
|
|
|
|
|
It means that when user press F1, help of the application will load in a special form. How can I do this?
Pls help!
|
|
|
|
|
Hi
You just use c# namespace
using System.Runtime.InteropServices;
Process.Start("Test.Chm")
so you can call anykind file using the above code and also connect to internet use these code
Sak
|
|
|
|
|
Thanks Sak,
What is the Process is?
|
|
|
|
|
See System.Windows.Forms.Help.ShowHelp
|
|
|
|
|
Hi All,
I have a smart part views which is calling a user control named "A". I want to call a another user control named "B" from previously loaded user control "A". Is that possible or otherwise i have to change the user control "A" to a smart view.
Please anyone help me in this, if possible with a sample code...
Thanks in advance,
Uma Shanker.K
|
|
|
|
|
when i double click in listview i want to do something i have 4 item i listview
but how i get item line 1 is id? line2 id? but idont know to use method
if (listview1.???????? = =1) { do somthing }
srry i begin
|
|
|
|
|
you can use listView.Items[...] property generally
in double click
and ListView.SelectedItems[...] Property or List.View.SelectedIndices[...] which the first one returns the selected ListViewItem and another one returns the index of the selected ListViewItem
and if you do not use multi selection you can simply access to the selected Item like
ListView.SelectedItem[0]
<br />
<br />
void listView1_DoubleClick(object sender, EventArgs e)<br />
{<br />
MessageBox.Show((sender as ListView).SelectedItems[0].Text);<br />
}<br />
good luck
|
|
|
|
|
|
can you give some hints about what exactly you mean about id?
Using the ListBox is very similar except it has too more ListBox.SelectedItem and ListBox.SelectedIndex Properties and another difference is it will return an object which must be casted to what you put inside for using it after retrieving from the list
and about showing things in ListBox
when you add something in listbox it simply use your object's ToString method for showing that in the list So all things you want to show from your class in the listBox must be set into overridden version of ToString method so it can show that.
Hope this one helps
|
|
|
|
|
As title really, i have an app with the ability to drag an item from a list box onto another grid type control, i can drag and drop no problem, i can also get the x,y coords of the mouse within the control when not dragging, but i need to get them when i have dropped the item onto the grid control. the problem is, the coords i am getting are not the withing the control but the screen ( i think ) any ideas how i can covert to the controls coords or how to get the coords from the control ??
Thanks in advance
Lee
|
|
|
|
|
hi
Point point = MyControl.ScreenToPoint(new Point(e.X, e.Y));
regards
|
|
|
|
|
i cannot see a function ScreenToPoint i have PointToScreen and PointToClient but not the otherway round ?? am i missing something here ??
Thanks
|
|
|
|
|
you want PointToClient
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
thanks, i finally sussed it after reading the first response... i just used
Point pt = Control.PointToClient( new Point( e.X,e.Y ) );
Thanks for the responses..
|
|
|
|
|
Hi All,
I have some block that occur in my catch ( try...catch ), this block is repeats a lot of time ( with different message but beside this message all the rest are the same ).
In C++ i would replace this block with some #define - but in C# i cant use ( of course ) this define.
My question is is there is something else that i can use to save line code in my project ?
Can i use something else beside writing all those 4 line in the block again and again and .... again....
I know that i can write some method and call it all the time - but i looking some other way.
Thanks for any help
|
|
|
|
|
No there is not.
"#define IDENTIFIER" is available for conditional stuff, there is no DEFINE
for code substitution.
go with the method !
And if you want to show the exception, show it in its entirity, that is
with ToString(), everything else sucks.
What's in those four lines anyway ?
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Yanshof wrote: I know that i can write some method and call it all the time
Well, why not?
Yanshof wrote: but i looking some other way
Why? What advantage do you think you will get?
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
"I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless."
My website
|
|
|
|