|
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
|
|
|
|
|
I think it's pest or cholera there. Either you create your control on the UI thread which then freezes while the control is being loaded, or you start a second thread with windows message queue and all for the control, but then you'll have to communicate with it via (Begin)Invoke, with all the overhead this requires.
|
|
|
|
|
Thanks for the reply. Do you have any pointers for documentation/examples on your second suggestion? There isn't too much communication between the form and its control, so the overhead might be bearable.
Thanks,
James
|
|
|
|
|
Sorry, I never did this and only vaguely remember having read about it.
Anyway, why do you need to load a control in the background? Usually loading a control doesnt't take so long that another thread makes sense. If it's because of many data or a huge image, you could load those in a (non-UI) worker thread.
|
|
|
|
|
It has several large-footprint controls on it(5 x DevExpress XtraGrids, an XtraLayoutControl, an XtraScheduler etc). They are all on tabs though, so I may try lazy loading on tab changes. I'm already using a background worker for making a service call to get data.
Thanks for the replies,
James
|
|
|
|
|
You're not going to gain anything there. The framework marshals BeginInvoke calls to the correct thread by posting messages; in this instance having the extra thread actually creates more work.
|
|
|
|
|
Hi,
I am new to the Visual C#, I have an application where I need to create the Combobox cells in the DatagridViewcolumn. I am able create the Comboboxes dynamically by replacing the DataGridviewTextBoxColumn Cell. The static Data to be updated in the ComboBox is from the dbc File, which can have any number of items. Here let us take 2 items from the dbc file, there is another source in the same datagrid from different column which data should be reflected in the ComboBox Cell but the items shall not be added, the only value shall be displayed in the combobox cell. Please help me .
modified on Tuesday, August 19, 2008 2:21 PM
|
|
|
|
|
Is there a way to Filter the DataGridViewComboBoxCell Items from the Display. Please give any clues.
SomaShekhar
|
|
|
|
|
Soma Shekhar wrote: Is there a way to Filter the DataGridViewComboBoxCell Items from the Display.
Yes
Soma Shekhar wrote: Please give any clues.
You can filter the DataSource[^]
led mike
|
|
|
|
|
mike Thanks for your help.
Using DataSource, DisplayMember, and ValueMember we can Filter.
I have an application where I have a NumericUpDownCell in the Column1 and ComboBox Cell in Column2 both are created Run time. I need to Display what ever the value updating in the NumericUpDownCell in the ComboBox Cell, but when user selects the ComboBox Cell in the Drop Down view only the item from the File needs to be displayed how can I acheive this. Example : I need to Display 0 to 254 in ComboBox Cell when updating the NumericUpdown. When user selects the ComboBox I need to show only 255 rest of the values shall not be shown in the Drop Down list.
Please provide a snippet of VC# code .
SomaShekhar
|
|
|
|
|
Soma Shekhar wrote: Using DataSource, DisplayMember, and ValueMember we can Filter.
No. Using whatever you used for the DataSource you filter the items.
led mike
|
|
|
|
|
Hi mike,
My application is some thing like threre are 2 datagridviews 1 with main data and the second displays the if any sub items in the main item. sub items can be value range, few selections, true or false type. In the second gridview I have NumericUpDownCell, ComboBox Cell. In the Sub Items there are only 2 values for the comboBox but the range of values can be 0 to 255, so when user selects ComboBox I need to display 0 ("Initial Value") and 255 ("Invalid Value"). When NumericUpdOwn is selected I have to increment/decrement values range from 0 to 255 and the 1 to 254 shall display in the ComboBox.
I have done some mimik based on your input but differently. When ComboBox is selected I have removed the rest of the items, if there is no event selectionchanged I have restored the item, but it causes a blank ComboBox for a short duration.
SomaShekhar
|
|
|
|
|
I'm having a difficult time understanding what your requirements are. For this reason I cannot suggest a specific solution. However in general, for cases that might require more complicated behavior a custom column might be a good solution.
led mike
|
|
|
|
|
Mike,
Thanks for your guidence, I will check it out, mean while what i did was I have added a Item when the value is changed in the Numericupdowncell and removed when combobox is selected. Now it is working fine.
SomaShekhar
|
|
|
|
|
I'm starting to work with Windows Forms application and need to show PDF files in my application. In future I might want extend functionality to show also Microsoft Office documents and HTML content.
I was thinking to use WebBrowser control, but is there any other options that I should consider? There is no need to let end-users to modify documents, just simply showing them.
|
|
|
|
|
Hi,
If you want to show the PDF files only for the time being then you can use MicrosSoft PrintPreview Control or you may go for any third party control. Take a look at http://www.componentone.com/[^][^]
Hope this helps .
Regards,
John Adams
ComponentOne LLC
|
|
|
|
|
Hello, I've got a question: How do you determin a user change to a trackbar to one done with the Value property (in code). Or if there is somewere to only catch the user one.
|
|
|
|
|
|
Can any help me in my query.
As i want to know how to build application that expired after installation of trial version.
THanks & Regards
Fahim
fahim_sk@hotmail.com
|
|
|
|
|
Do you have the code for the program?
If you don't, you can't.
Anyway, re-building it doesn't work! You need (if you have the code) to remove the liscense part.
|
|
|
|
|
I think he may have meant "that expires after..."
In which case, you probably need a third-party registration system. There are several available--I think CNET Download.com offers one, but don't know much about it. There are probably better ones out there.
Of course you could do it yourself, but I'm assuming that since you're asking how, you probably don't want to figure it out on your own. Not that it's that hard, but I suggest doing a bit of research on the topic and asking a more specific question if you can't figure something out.
“Time and space can be a bitch.”
–Gushie, Quantum Leap
{o,o}.oO( Looking for a great RSS reader? Try FeedBeast! )
|)””’) Built with home-grown CodeProject components!
-”-”-
|
|
|
|
|
There are some nice tools availeble for this, for example: Software Shield[^].
You can create your own, just store the time of installation somewhere and when you application starts it checks if the trial time isn't expired. If it is expired you inform the user and exits.
When you create your own, you have to remember that the user can adjust his system clock. So you have to build in that simple security also.
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
I am working on a Windows Application where I have a button that creates tabs in my Tab Control at run-time. The controls inside of those tabs are obtained from a User Control which I created. I would like to now add functionality to allow a user to close each particular tab with a button inside each tab that gets created at run-time. I am having a hard time figuring out how to access the tab control (located in the main form area) from within the User Control to accomplish this purpose. If anyone has any ideas or suggestions, it would be greatly appreciated!!!
|
|
|
|
|
Probably delegates
There ws something similar in one of my earlier projects and Delegates made that possible.
|
|
|
|
|
It's not considered polite.
|
|
|
|