|
K.v.S. wrote: Is this the reason I get the incomplete coverage result, and how do I cope with it?
That is plausible.
You could add tests for the base class itself.
Or you could add another derived class that does need the specific base class code, and test it.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Hello i need to set a query string to null or empty after it had a value can any body assist me??
|
|
|
|
|
Try to explain that again please.
If you want to set a string to null, which probably is not want you want, you can do...
string s = "something";
s = null;
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
I have a query string that is used in a page.
i sent this url from pop up page lets say
window.opener.location.href = window.opener.location.href +" 'Id=1'";
but after i get the Id
request.queryString["Id"]
i want it to be string.empty or null i simply want to remove it or assign to it a value so i will not check it again.
|
|
|
|
|
Well that makes more sense, but I cannot help you I'm afraid, try posting in the Web Development forum instead next time.
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
QueryString collection is readonly, it can not be modified.
Coding C#
www.excitetemplate.com
|
|
|
|
|
Hi guys,
I need some help please. I have a parent form (mdi) where a context menu item click opens up a child form, that child form takes a long time to load and so I wish to somehow allow the user to be able to click on a different context menu item click while child form A is being loaded.
Please advice of a way of doing this.
Thank you in advance.
Sameer
|
|
|
|
|
Your initial thought of thread is correct. However, you have to do all GUI stuff on the GUI thread, including the showing of the form. What you could do instead of this is move the code which is invoked when you show child form A onto a different thread. Just make sure that you use the Invoke method of child form A if you need to actually fiddle around with the controls.
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
Thank you for your prompt response. Is there any way you could give me an example. I tried using a background worker but that doesn't work because of MTA restrictions. I was getting a dragdrop.... error. I tried initiating a regular thread and that is not working either because of what you suggested "GUI stuff on the GUI thread" All I am doing is GUI stuff, here is the code in my button click on mdi to open child form A
try
{
this.Cursor = AdvancedCursors.Create(Path.Combine(Application.StartupPath, "wagtail.ani"));
if (frm2 != null)
{
frm2.Close();
}
frm2 = new frmGrid2(m_ADBCnn, TechnicianstoolStripMenuItem1.Text, frm1);
frm2.CellClicked += new CellClickedEventHandler(frm2_CellClicked);
if (frm1 != null)
{
this.frm1.CellClicked += new CellClickedEventHandler(this.frm2.frm1_CellClicked);
this.frm2.CellClicked += new CellClickedEventHandler(this.frm1.frm2_CellClicked);
}
frm2.Show();
frm2.MdiParent = this;
this.VerticalTiletoolStripMenuItem1.PerformClick();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
Sameer
|
|
|
|
|
There are three things which could cause the delay:
this.Cursor = AdvancedCursors.Create(Path.Combine(Application.StartupPath, "wagtail.ani"));
frm2 = new frmGrid2(m_ADBCnn, TechnicianstoolStripMenuItem1.Text, frm1);
this.VerticalTiletoolStripMenuItem1.PerformClick();
Which of those lines causes the delay? You can find this out by stepping through the code and seeing which line seems to take longer to execute.
When you know which line takes the longest time to execute, put it into a separate thread.
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
It's definately frm2 = new frmGrid2(m_ADBCnn, TechnicianstoolStripMenuItem1.Text, frm1); and frm2.show(). The part that takes long is the loading of the child form because it pulls quite a bit of data so it opens it but then the grid in child form is blank until all data is pulled.
Sameer
Sameer
|
|
|
|
|
What you need to do is get the data in a separate thread. In the GUI thread, set the grid's data source to your table. Then start the separate thread which adds the data to the data source. The grid should get updated automatically.
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
Pardon my ignorance as I am not the best in using threads. Currently on load of child form I am calling the runworkerasync method of the background worker with retrieves data and upon completion assigns dataset to grid and formats the grid.
Here is the change I have made and I am getting an error of cross thread operation.
worker1
Async in form load
do work retrieves data from database
Completed calls Worker2Async
Worker2
Async in Completed of Worker1
Do work assigns datagridview datasource to dataset containing data retrieve by worker1
Completed formats the grid
I am getting an error in Do work for Worker 2, when I call datagridview.datasource=dataset, it says cross thread operation... datagridview accessed from a different thread then the one it was created in... Any suggestions, am I doing what you suggested?
Please help
Sameer
|
|
|
|
|
You only need one worker that gets the data from the database.
The form should kick off the background worker, then format it's datagrid as appropriate on the UI thread. ANY interaction with a control MUST be done on the UI thread, not from a background worker.
When the data fetching background work finishes it's job, just the the grid's DataSource property to the data returned.
|
|
|
|
|
Thank you Dave for the guidance. I have switched my code back to your suggestion for the most part. I now have a background worker that does the following:
On form load I am calling the runworkerasync
dowork: retrieves all the data to database and assigns it to a datatable
Completed: Assigns datatable to datagridview datasource
Now I need to run a format grid function that goes through the grid and formats some cells. Where do I call that, should I call that in the completed of the worker?
Please advice
Sameer
|
|
|
|
|
Hi,
the basic idea is:
- long computations (including waiting on a database or a network...) belong in a separate thread, which could be a BackgroundWorker or a ThreadPool thread or a real Thread instance.
- manipulations of Controls (including Forms and DataGrids) need to run on the main thread
You can organize that with BackgroundWorkers, as they have two events (Progress and Completed) that always will run on the main thread; or you can get similar results with Control.Invoke
I have a little article[^] that explains more.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Private StringBuilder sb=null
private void CutCopyPaste(bool Cut, bool Copy, bool Paste)
{
foreach (Form f in this.MdiChildren)
{
if (f.ContainsFocus)
{
foreach (Control c in f.Controls)
{
if (c.Focused)
{
if (c.GetType() != typeof(Label))
{
if (Cut)
{
sb.Append(c.Text);
c.Text = "";
}
else if (Copy)
sb.Append(c.Text);
else if (Paste)
c.Text = sb.ToString();
break;
}
}
}
}
}
}
private void copyToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
sb = null;
sb = new StringBuilder();
CutCopyPaste(false, true, false);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void pasteToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
if (sb != null)
CutCopyPaste(false, false, true);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void cutToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
sb = null;
sb = new StringBuilder();
CutCopyPaste(true, false, false);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
It is the complete code for cut copy and paste but if we take textbox inside the container like groupbox,panel etc. its not working ...and i want also include the feature Undo and SelectAll...how can i do this...
|
|
|
|
|
Group and Panel controls have their own Collection of controls. So once you find one of these controls you have to do a foreach() to access the controls that it holds.
You can use a recursive method to access the control you are looking for, or write code to access these special cases.
My choice would be recursion since it will handle the nesting of these special cases.
|
|
|
|
|
yes u are right...how can i acess those controls that it holds...
guide me...
|
|
|
|
|
Try something like this (not tested).
public void ProcessLabel ( Control.ControlCollection c )
{
foreach ( Control control in c )
{
if ( control.Controls.Count != 0 )
ProcessLabel ( control.Controls ) ;
if ( control is Label )
{
}
}
}
Call it like
ProcessLabel ( Controls )
If you need to send more parameters, modify the method but be sure you also add them to the recursive call as well.
public void ProcessLabel ( Control.ControlCollection c, bool cut, bool copy, bool paste )
{
foreach ( Control control in c )
{
if ( control.Controls.Count != 0 )
ProcessLabel ( control.Controls, cut, copy, paste ) ;
if ( control is Label )
{
}
}
}
|
|
|
|
|
how to call this method...
processlabel(whichcontrol);
|
|
|
|
|
You can change the signature like this to add the specific label control you are interested in processing.
public void ProcessLabel ( Control.ControlCollection c, Label label )
{ foreach ( Control control in c )
{
if ( control.Controls.Count != 0 )
ProcessLabel ( control.Controls ) ;
if ( control is Label && control.Name = label.Name )
{
label.ForeColor = Color.Red ;
}
}
}
How to call this method
ProcessLabel ( Controls, myLabel )
If you need to send more parameters, modify the method but be sure you also add them to the recursive call as well.
public void ProcessLabel ( Control.ControlCollection c,
Label label,
bool cut,
bool copy,
bool paste )
{
foreach ( Control control in c )
{
if ( control.Controls.Count != 0 )
ProcessLabel ( control.Controls, label, cut, copy, paste ) ;
if ( control is Label && control.Name = label.Name )
{
label.ForeColor = Color.Red ;
}
}
}
|
|
|
|
|
I am trying But its not working...have u run this..
|
|
|
|
|
The reason it fails is because you're not doing a recursive search through the child controls of the Form. You're only looking at the top level of the controls - controls are hierarchal in nature. I would definitely recommend reworking your code to be more modular or atleast rely on a different method of finding the focused control.
One method might be hooking up a listener for the focused event on every control (assuming you don't have 1000+ controls) - see this[^].
You might also consider using the clipboard to maintain the text to be copied rather than the stringbuilder you've got - see this[^].
|
|
|
|
|
hi,
I am using following connection string but one ISAM error comes whenever I run the application.
Kindly check the mistake that, What am I doing wrong?
Thanx in Advance
(Riaz)
"Provider=Microsoft.ACE.OLEDB.12.0;Data Source="+ strDBPath +"stockmain.accdb;Jet OLEDB:Database Password=abc;SET EXCLUSIVE=OFF;");
|
|
|
|