|
Hi all,
I want to see print previw of my resulted form......but am trying with many ways it is just displaying empty form only.it is not going to disaply the content of my windows form....can u plz give for that solution.
this is my code....
private void printPreviewToolStripMenuItem_Click(object sender, EventArgs e)
{
printPreviewDialog1.Document = this.printDocument1 ;
printPreviewDialog1.FormBorderStyle = FormBorderStyle.Fixed3D ;
printPreviewDialog1.SetBounds(20, 20, this.Width, this.Height);
if (printPreviewDialog1.ShowDialog()== DialogResult.OK)
{
this.printDocument1.Print();
}
what is the wrong of code and why it is diplaying empty form when i click the printpreview option.
Can u plz give me quick reply
modified on Friday, December 5, 2008 6:46 AM
|
|
|
|
|
Hi,
I have just got the handle of using a background worker in order to mutithread my application. However from all the examples I've seen it appears that EVERYTHING invloved in the background worker thread must be within the DoWork event - not very object orientated!
How do I call a method of another object WITHIN that separate thread and have the intricasies of such a method be reported back to the background worker?
For example:
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
Assessment.Update()
}
I would like Assessment.Update() to be able to ReportProgress back to backgroundWorker1 in addition to any ReportProgress which may happen after Assessment.Update() has completed.
Many thanks
|
|
|
|
|
eddy556 wrote: it appears that EVERYTHING invloved in the background worker thread must be within the DoWork event
Yes - The thread executes for the duration of your DoWork delegate.
You can call methods on objects just like you would anywhere else.
As with all multithreading, if objects are used by multiple threads
simultaneously then you may need to provide synchronization.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
... and you can pass the BGW to the methods you call, so they can call BGW.ReportProgress to report progress.
Or you can organize a delegate.
|
|
|
|
|
|
hi guys,
I came accross a wierd issue /behaviour I am trying to fix since 2 hours. But I dont know really how.
I got a combobox and I assign a datasource(a List<class>) to it, like this
radComboBox1.DataSource = DAAngebotssoftwareDaten.Instance.BasisDaten.List;
radComboBox1.DisplayMember = "Bezeichnung";
radComboBox1.ValueMember = "ID";
radComboBox1.Text = "Please select...";
radComboBox1.SelectedValue = null;
and thats how I set the datasource for the other comboboxes using this list data.
If I select a listitem of one of the comboboxes, all the other comboboxes get this value I just selected assigned too.
why is this? I mean, the list hasnt changed, I just selected a value of one of the comboboxes. the values of all the other comboboxes should stay what they were.....
Explanations and suggestions how to0 get around this issue are very welcome ( i am using vs 2008 )
Thanks
Cheers
Thomas
|
|
|
|
|
Hi,
yes, that is a feature of data binding: AFAIK all Controls bound to the same data source will show the same selection, even when located on different forms. The advantage is the selections will be consistent throughout your app. The disadvantage obviously is you do not always want such behavior.
if you don't want this to happen, you should use different copies of a data source for independent Controls.
so it is not due to the compiler nor the IDE, it is by design of data binding.
modified on Wednesday, December 3, 2008 12:50 PM
|
|
|
|
|
Luc Pattyn wrote: you should use different copies of a data source for independent Controls.
Isn't that one reason to use DataView[^] as a DataSource?
led mike
|
|
|
|
|
Hi Mike,
I am not sure, I haven't used any DataViews yet.
Anyhow they could only help for DataTables, the OP started of with a List.
|
|
|
|
|
Luc Pattyn wrote: the OP started of with a List.
Yeah, I couldn't tell what he's using because of the German stuff.
led mike
|
|
|
|
|
well.... its wierd by design of data binding...
but thanks for that mate.
Cheers
thomas
|
|
|
|
|
When T try to write connectionstring I have error with c#
connectionstring:
code C#
con.ConnectionString="Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Test;Data Source=HASSAN-2D6107E7\SQLEXPRESS";
error message :Error 1 Unrecognized escape sequence
but when try to use the same connection string using vb.net no error
why dose not c# support "/"?
Ahmed hassan
|
|
|
|
|
hassanasp wrote: why dose not c# support "/"?
It looks like '\' is the problem, not '/'.
Maybe try
con.ConnectionString=@ "Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Test;Data Source=HASSAN-2D6107E7\SQLEXPRESS";
*edit* More info: C# String Literals[^]
Mark
Mark Salsbery
Microsoft MVP - Visual C++
modified on Wednesday, December 3, 2008 12:17 PM
|
|
|
|
|
Hi
Does anybody know how to assign IP address or addresses to a network card. After successfull addition, I should be able to pink to that IP address from another machine.
Another questions:
Can One network card have multiple IP addresses?
Thank you.
|
|
|
|
|
I'm not sure what the .NET equivalent is, but the native IP Helper[^]
APIs can help.
For example: AddIPAddress Function[^] (check the remarks section for more links)
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi
I know that there is a straightforward way to load an assembly in run-time using Assembly.Load and then we can get its types using its GetTypes method.
But that solution has some problems, for example if you try to load an assembly in another directory rather than your project directory (and the assembly has some dependencies to other assemblies) you will get an exception saying it can not load the assembly or one of its dependencies.
I'm working on a design time tool and I want to show a list of types that are included in current solution in a UITypeEditor(Something like a tool that Workflow designer has when you want to pick a ExternalDataExchange).Since this list is being build in design time I just need the name of types(and may be to check if they have some attributes attached to them) and I don't want to load them.
So here I have a question to ask.How can I get a list of type names of classes in current solution in Visual Studio IDE?
Thank you
|
|
|
|
|
I need to update a datatable from a datasource silently. That is, I need to do regularly refresh data in datatable from its source database (MS Access database) without greatly interrupting the user experience. I don't want to clear the table and fill it from an OleDbDataAdapter, but use some other method. Any suggestions would be appreciated.
Thanks.
|
|
|
|
|
If you don't want that the UI goes to nonresponding state, use BackgroundWorker[^] class to fetch the data.
When fetching the data n DoWork method, use OleDbDataAdapter, OleDbDataReader or what ever is suitable.
|
|
|
|
|
Thanks, Mika. I had thought of a BackgroundWorker, but I was also hoping to retrieve updates while preserving any changes the user was making to the current DataTable. The DataTable.Merge(DataTable) method, where the DataTable passed into the method reflects the current state of the database) seemed like a good option to me, but I have not been able to get the Merge method to work.
If you have any suggestions regarding how to use the Merge method, or any relevant articles to point me to, I would appreciate it.
Thanks.
|
|
|
|
|
polishprogrammer wrote: but I have not been able to get the Merge method to work
Could you post what you've done so far and what's the problem. Otherwise it's hard to give any hints.
|
|
|
|
|
Afternoon all !
I have populated a list with various animal objects - 'Cat, Dog, Lion, Tiger....'
I am stepping through the list in order to have them call specific methods.
The Cat & Dog object both have the same method Pet(). None of the other animals in the list have this method.
If i implement 2 seperate statments -
foreach (Cat thisCat in zooAnimals.OfType<Cat>())
{
thisCat.pet();
}
foreach (Dog thisDog in zooAnimals.OfType<Dog>())
{
thisDog.pet();
}
the code will work fine.
I would like to know for my own benefit if there's a way to concatenate these statements into 1
i.e
foreach (Cat thisCat in zooAnimals.OfType<Cat>() || Dog thisDog in zooAnimals.OfType<Dog>())
{
thisCat.pet();
thisDog.pet();
}
Thanks in advance
Neil
|
|
|
|
|
The way to do this is to create an interface called IPettable with a single method Pet() .
You then implement this interface for Cat, Dog and any other animal you might want to Pet.
Your code then becomes:
foreach (IPettable pettableAnimal in zooAnimals.OfType<IPettable>())
{
pettableAnimal.pet();
}
|
|
|
|
|
You could do this by implementing an extra interface and then iterating over this interface. Like this:
interface IHasPetMethod
{
void pet();
}
foreach ( IHasPetMethod hasPetMethod in zooAnimals.OfType<IHasPetMethod> )
{
hasPetMethod.pet();
}
This makes the intention of the programmer somewhat clearer (if there is a pet() method, then call it). But compared with your original approach, it's largely a matter of taste and coding style.
Regards
Thomas
www.thomas-weller.de
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. Programmer - an organism that turns coffee into software.
modified on Wednesday, December 3, 2008 11:26 AM
|
|
|
|
|
Not really - because OfType<T> takes a specific type you can't interchange between Dog and Cat unless they share some common type (other than 'Animal' which I'm assuming is your base type).
My preference would be that Cat and Dog both implement an IPet interface:
<br />
internal interface IPet<br />
{<br />
void Pet();<br />
}<br />
so that when you're doing your look you call
<br />
foreach (IPet pet in zooAnimals.Oftype<ipet>())<br />
{<br />
pet.Pet();<br />
}<br />
</ipet>
FWIW, I assume you're using yield return in your OfType<t> - it's more efficient than creating an intermediary IEnumerable object to store the results before returning them?
HTH
It definitely isn't definatley
|
|
|
|
|