|
If you need to stop user going to the second tab before finishing first tab, set a flag variable, and update it when the process finishes in the first tab. When user clicks the second tab, handle the event and check the flag value. If the process is not completed, set the SelectedIndex value to select the current tab again.
Alternatively, you can disable all the controls in tab page, but user will be able to see that tab. For that use the following code
Control cn = tabPageName as Control;
cn.Enabled = false; Hope it helps
|
|
|
|
|
I'm currently using this 'setting a flag' option. But i thought, there may be some another option for this... so i did asked the question.
Thanx for help...
|
|
|
|
|
Have you tried my second approach ? As CG said, tab control is not the appropriate control for this scenario. CP having an article on using wizards with winforms. Do a search for that.
|
|
|
|
|
My one cent to this. You can group all controls in different tab panels and in individual panel controls.
Now you can use your flag to enable or disable the panels.This is the same idea navneeth said but just to ease the number of controls you need to enable or disable.
May be you can consider setting the flag to do this in the tab change event.
Thanks
Laddie
Kindly rate if the answer was helpful
|
|
|
|
|
hi
i m newbie on C# I have created a usercontrol that has a datagridview i use this control on my parent form, the problem is that i want to set the datasource property of my usercontrol the same as my parent form so that
gridview shows the data of the datatable of parent form's dataset'
my coding is like this is it work fine
public partial class UserControl1 : UserControl
{
public DataSet ds;
public DataTable dt;
public UserControl1()
{
InitializeComponent();
}
public dataset ds
{
set
{
this.ds = value;
this.dgvSearch.datasource = ds;
}
get
{
return ds;
}
}
public DataTable dt
{
set
{
this.dt = value;
this.dgvSearch.DataMember = dt;
}
get
{
return dt;
}
}
or m missing something any sort of help will be highly appreciated
Thanks
|
|
|
|
|
saneng wrote: public DataSet ds;
public DataTable dt;
Make these variables to private.
saneng wrote: public dataset ds
{
set
{
this.ds = value;
this.dgvSearch.datasource = ds;
}
get
{
return ds;
}
}
Change the name of this property as you variable and property names are same.
public Dataset ControlDataSet
{
set
{
this.ds = value;
this.dgvSearch.datasource = ds;
}
get
{
return ds;
}
}
|
|
|
|
|
i implemented list class in (web project).
public class person<br />
{<br />
string name;<br />
<br />
}<br />
public partial class fout : System.Web.UI.Page<br />
{<br />
protected void Page_Load(object sender, EventArgs e)<br />
{<br />
List<person> obj = new List<person>();<br />
}<br />
}
i am getting error
The name or namespace List cannot be found
Should i add any reference ?
Yesterday is a canceled check. Tomorrow is a promissory note. Today is the ready cash. USE IT.
modified on Friday, March 7, 2008 1:32 AM
|
|
|
|
|
You need to use System.Collections.Generic namespace.
|
|
|
|
|
ThankQ
Yesterday is a canceled check. Tomorrow is a promissory note. Today is the ready cash. USE IT.
|
|
|
|
|
I'm surprised that the classes don't include it by default, they still include the old one. But then, when the IDE adds a method stub, it will throw an Exception and not a NotYetImplimentedException, so...
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
ok i only know very little a made a form1 and a form2 what i do is hide form1 and open form2 now
what i need to know is how then can i close form2 and reopen form1 anyone please
|
|
|
|
|
Not very clear about the way both forms are being used in your application.
However, please know that if a Form has been hidden only using Hide() method, it may be shown again by calling Form.Show() method.
Any Form can be closed by calling its Close() method. If a form has been closed you may creating a new object of the form and call its show method.
-Dave.
Dave Traister,
ComponentOne LLC.
www.componentone.com
|
|
|
|
|
i do know console programming in c++ you can go to www.planetsourcecode.com and serch Gregory W Bryant under C++ to see my programs but i dont know really any c# and i created the first form as a login the second displays a buddy list now on the second one i have a log out button that i want to close the second form and open the original first form not a new object i have everything done but reopening the first form
|
|
|
|
|
The big tragedy of winforms and designers is that so many people create forms before they learn a little coding, then they get stuck down the line. I would advocate learning console stuff first.
Having said that, if you want to hide form1 while form2 is visible, your best bet is to turn them both into controls and switch which one is visible on a single form.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi friends ..
I have one doubt regarding one 3rd party DLL.I want to generate new DLL.
My logic is
1. import 3rd party DLL
2. new dll = 3rd party dll
3.create new dll
is my way is correct?please explain me!!
*****THANKS N ADVANCE****
Mathen.K
(I WILL TRY MY LEVEL BEST )
|
|
|
|
|
If you only want to use a third party DLL you may simply add reference of DLL in your project and create an object of the class.
If you want to inherit the existing DLL and want to extend functionality of existing class or control, by creating your own custom class library. Use following steps-
1) Start a project of type class library .
2) Add reference of existing DLL file.
3) Inherit the existing class, such as –
public class Class1:ExistingDll.ExistingClass
{
public Class1()
{
//
// TODO: Add constructor logic here
//
}
}
After this you may extend functionalities of existing class.
I hope this helps.
-Dave.
Dave Traister,
ComponentOne LLC.
www.componentone.com
|
|
|
|
|
Browse for a file and open the file.
It browses fine; but when i open the folders am unable to see the contends.My basic idea is to browse for a file and select the file inside the selected folder.
My code is
private void btnBrowse_Click(object sender, EventArgs e)
{
FolderBrowserDialog dialogObj = new FolderBrowserDialog();
dialogObj.RootFolder = Environment.SpecialFolder.MyComputer;
if (dialogObj.ShowDialog() == DialogResult.OK) ;
{
OpenFile();
MessageBox.Show("Hello Jane");
}
}
public void OpenFile()
{
OpenFileDialog obj = new OpenFileDialog();
obj.OpenFile();
}
}
}
Am not sure where am going wrong or what has to be done.
Thanking You
|
|
|
|
|
I recommend you give this up and buy a basic book on C#, so you can start at the beginning. You're obvioulsy guessing what to do here.
obj.ShowDialog will show the open file dialog. Then you check the DialogResult to see if the user clicked OK, and then you have a file selected. Even then, obj.OpenFile is not magically going to open the file in your program. You have a ways to go, take a step back and learn some basics.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Just wondering, if you do a Switch stateemtn like this.
Switch var1
case "1":
DoStuff()
case "2":
DoStuff()
case "3":
DoDifferentStuff()
is it possible to group the DoStuff cases, with some sort of OR statement like...
Switch var1
case "1" || "2":
DoStuff()
case "3":
DoDifferentStuff()
|
|
|
|
|
case "2":
case "3":
Dostuff();
break;
Note, you cannot do this:
case "2":
DoCase2Stuff();
case "3":
Docase2and3stuff();
break;
Because C# switch statements are dumbed down on the assumption that the user is stupid.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Christian Graus wrote: Because C# switch statements are dumbed down on the assumption that the user is stupid.
Which is true, usually.
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
Christian Graus wrote: assumption that the user is stupid
No, that some users are much smarter than others, creating too wide a gap in developer abilities; and as they couldn't make the stupid ones smarter, their only recourse was to handicap the smart ones, thereby leveling the playing field.
|
|
|
|
|
I would like to display read-only information on a tab page by simply drawing it using GDI (TextRenderer.DrawText). The problem I'm having is that the text is not persisted by the tabPage surface itself. If I select a different tab then switch back the text is lost with the redwaw. If I use Label controls the control handles persisting the text. What do I need to do to be able to draw on a tab page and have the text stay there until I'm ready to change it? Labels aren't going to cut it.
-Roger
|
|
|
|
|
Well, if it doesn't persist, sounds like you're using CreateGraphics instead of a paint event, just like the fellow below.
You really need to post code if you want us to help you.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
The previous reply is correct, you will need to use paint event of TabPage.
Drawing a line of text should be as simple as using following code in paint event-
Graphics g = e.Graphics ;
g.DrawString("Some text",MyFontObj,Brushes.Black,10,10);
I hope this helps.
-Dave.
Dave Traister,
ComponentOne LLC.
www.componentone.com
|
|
|
|