|
I suspect you must have some reasons for not doing this, but wouldn't this be more straightforward if you just stripped the controls from the base form that don't actually appear on all the derived forms, and just leave a hole where these replaceable controls go?
|
|
|
|
|
Thanks for your reply.
Actually I have 8 derived forms which use 15+ identical controls. But for 1 of these derived forms, 4 controls have to be replaced.
What you suggest, tell me if i'm wrong, is to remove these 4 controls from the base form and add them in each derived forms (7 here). But if i do that i'll loose the factorisation benefit for these controls.
|
|
|
|
|
You could derive in 3 steps:
Form1 without the 4 controls
Form2 = Form1 + 4 controls type 1
Form3 = Form1 + 4 controls type 2
and 7 forms derived from Form2
|
|
|
|
|
Thanks Frank.
That's a clean and acceptable solution since you don't have to deal with many controls on many derived forms. I simplified the example to make it clear but if i do that in my real case, i will multiply the depth of inheritance and the forms without a functional purpose.
|
|
|
|
|
I've seen this question in various forms in several places, but I have yet to see a satisfactory solution.
Using .Net Framework 2, I've got a DataSet with elements bound to several TextBoxes which are scattered on several tab pages on a form. I can then change any of the TextBox texts, and the corresponding changes do appear in the DataSet.
I want to enable an Apply button when any of these elements have changed. I tried to use the DataSet's HasChanges, but it will not return a 'true'. I also tried a RowChanged event on one of the DataTables in the DataSet, but it never triggered. I tried to resort to using the TextChanged event from all the TextBoxes. That almost works, but the event is raised when the binding initially sets the TextBox contents. I can tolerate that on the first tab page of my form, but the TextBoxes on the other tab pages don't get set until you initially select those tabs, and it is difficult to distinguish between a user-initiated change and the original setting.
Thanks for your suggestions.
|
|
|
|
|
This is what I do. Have form level boolean bLoading instantiated to True, do your binding in the formloading event, the last thing in the formload event is to set bLoading to false and turn off the save button.
bLoading can also be used to short circuit the combo selection events and any selected index change events during the loading by putting If bLoading then Exit Sub/function in the event method.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I think I am actually doing the equivalent. I'm loading the DataSet in formload, and then I disable the 'apply' button (or 'save', etc). Then, any subsequent edits of the TextBoxes will raise their TextChanged events and I can then enable 'apply'. The problem shows up on the additional tab-pages that I have on the form. Their TextBoxes don't seem to receive the bound data until the user clicks on the tab-page, and this raises their TextChanged events. And this seems to occur after the tab-page's Enter event is raised, so I can't find a good place to re-disable the 'apply'.
|
|
|
|
|
Don't know if it works, but maybe you can fire the load/enter event of each tabpages when the form is loading. All bindings should have been done after that.
Or you can have a boolean for each tabpages that determines if it's the firs load or not.
Not very good solutions. It's a shame you can't use events related to your datasource.
|
|
|
|
|
rtklueh wrote: Their TextBoxes don't seem to receive the bound data until the user clicks on the tab-page,
Interesting, I have never actually bound 1 record to multiple tab pages, I must try this to verify the event sequence. As seven suggested you could use the tab changeindex to manage the button state but it is ugly.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I think it's strange that I wrote my own control, sort of an editable list control thing (I don't like the DataGrid), and it seems to set the DataSet HasChanged properly (I think because my control does BeginEdit and EndEdit). I don't understand why the TextBox doesn't do as well? Like the English guy with the vacuum cleaner says, 'things just ought to work properly'.
|
|
|
|
|
Thanks everybody for the comments.
It looks like the 'Enter' event for each of the tab pages occurs before the controls on that page are updated from the DataSource. And it looks like the 'SelectedIndexChanged' from the tab control occurs after the updating. So, I can set a flag while any of the pages are being updated and ignore any of the 'changed' events from any of the controls during that time. Not too pretty, but it seems to do the job.
|
|
|
|
|
Hello All,
I am totally new to Windows Service. Trying to develop Windows Service that run only 4 days in a year ie 1st Jan, 1st Apr, 1st Jul and 1st Oct (Quarterly basis).
I took a timer but not able to set the Interval. I need to download data from some website on these days and push that data in Database.
Can some one help me in setting the timer ...
Also can I debug this service to check whether its working fine...
Please help me...
Thanks in advance...
|
|
|
|
|
You don't need to create a service. It's easier to create a simple console aplication and run it at required times using windows scheduler.
Pavel
|
|
|
|
|
Thanks Pavel. Would u pls give me a start for the same...
Thanks again...
|
|
|
|
|
You can attach the debugger to the service after it is running, and then set breakpoints in it to stop it and look in on things. If you need to see what it is doing when it first starts up, then just add some code to your service to sleep for a minute or so to give you time to attach the debugger right after you start the service.
|
|
|
|
|
Hi !
Why don't you use windows scheduler to run your your program?
To have debug infomation make sure that you write all needed infotmation in a file for exemple.
|
|
|
|
|
Thanks for the reply.
Would u pls give me a start for the same...
Thanks again...
|
|
|
|
|
In crystal report, you can select the printing direction in Layout tab between "Across then Down" and "Down then Across."
I was wonder how to do this in local RDLC report or is rdlc even have this option?
|
|
|
|
|
I'm looking to create a VBS that will query the RSoP and return the security settings of the system e.g. account policys, local policys, event log etc.
So far with a bit of research i have this, however this seems to just display password details - min password age, lockout duration, min max length etc.
strComputer = "."
Set objWMIService = GetObject _
("winmgmts:\\" & strComputer & "\root\rsop\computer")
Set colItems = objWMIService.ExecQuery _
("Select * from RSOP_SecuritySettings")
For Each objItem in colItems
Wscript.Echo "Key Name: " & objItem.KeyName
Wscript.Echo "Precedence: " & objItem.Precedence
Wscript.Echo "Setting: " & objItem.Setting
Wscript.Echo
Next
Can anyone help me further or point me in some directions.
Cheers
Gary
|
|
|
|
|
I am trying to invalidate one mdi child form from another to call PanelDraw.Paint- basically refreshing one form based on user input from another (using VB.net 2008). The form I'm trying to refresh/invalidate is called "GraphicsViewer" and I'm currently using
GraphicsViewer.Invalidate()
GraphicsViewer.Update()
from the user input form. The GraphicsViewer form seems to be updated but the panel does not actually get refreshed until the GraphicsViewer form is minimized then maximized again. I am not finding a solution online- is it possible to do this?
I have tried using GraphicsViewer.TopLevel = True before calling Invalidate() with no luck.
|
|
|
|
|
Member 2512391 wrote: I am trying to invalidate one mdi child form from another
That would be a Bad Practice or Bad Design. See Model-View-Controller[^] where one principle is that Views should not be coupled.
led mike
|
|
|
|
|
I am currently working on a program that have external program window in one of his controls.
This external program in the form control is focused standardly.
But when i want to click something on the mainform i have to click twice before the options is selected.
And i have to press CTRL + TAB twice to get another program focused.
How can i attach this external program to my form so they both hold the focus ?
I have tryed many things with Win32 API Calls but nothing works.
So has anyone an idea how to handle this ?
|
|
|
|
|
2 different application can't have focus at the same time. Have you seen anything like that before?
Ahsan Ullah
Senior Software Engineer
|
|
|
|
|
Yes its possible i have seen this before.
Because the second program in this task putty is opened in a user defined control.
I have before that when you activate the program in the usercontrol that mainform is activated to.
And we have a direction in which we are searching for a solution but we have not found an fix yet.
AttachThreadInput is an API user32 Call we are trying to use for this problem and a couple of other calls. But with the last 4 time the computer crashed totally because af an incorrect call.
|
|
|
|
|
Hi,
I'm working with C# on .NET 3.5SP1. What I'm trying to achieve is as follows:
I have a form (frmShell) which can "spawn" other forms. Each of the other forms (frmMyFormType, for example), has a main content panel, into which I add a control of an appropriate type (cntMyFormTypeView, for example). Whilst the control is loading, I display a loading panel (cntLoader in my case).
In the constructor of each form I create a loading panel, and add it to the Controls of the content panel like this:
var Loader = new cntLoader { Dock = DockStyle.Fill };
contentPanel.Controls.Add(Loader);
In the Form_Load event, I then start a background worker, whose DoWork method looks something like this:
e.Result = Invoke(new CreateViewInvoker(CreateView), parameters.ObjectIdentifier);
Where CreateViewInvoker is defined with the following:
private delegate cntMyFormTypeView CreateViewInvoker(long itemId);
And the CreateView method is as follows:
private cntMyFormTypeView CreateView(long itemId)
{
return new cntMyFormTypeView(this, itemId) { Dock = DockStyle.Fill };
}
In the Completed method of the background worker, I do the following:
var control = (Control)e.Result;
contentPanel.Controls.Clear();
contentPanel.Controls.Add(control);
contentPanel.Invalidate();
The problem: this works, but freezes the UI when I Invoke the CreateView method (the constructor of cntMyFormTypeView can take a long time to run). This does make sense since it will be invoked on the UI thread.
Does anyone have any suggestions as to how to do this differently such that I create a control in the background (without locking up my UI), but then still use it from my UI thread?
Thanks,
James
|
|
|
|