|
hmmm..... sounds good.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
You are almost right
Array.ConvertAll will convert the array, and all the objects included in the array will have the right type (t.GetElementType() in my example)
The problem is, that Array.ConvertAll returns a reference who is an object[], and, when i use this object as a parameter to a method, that gives me an InvalidCastException because it cannot convert from object[] to myType[], i mean, if you want to convert to string[] you may just write
string[] test = (string[]) Array.ConvertAll....
But here the type is given dynamicaly
I fixed it using a not very good strategy, but it works, here is the code:
public object ConvertTo(Type t, object value) {
if (t == null) {
return value;
}
if (t.IsEnum) {
return Enum.Parse(t, value.ToString());
}
if (t.IsArray) {
object[] _valArr;
if (value.GetType().IsArray)
_valArr = value as object[];
else
_valArr = new object[] { value };
Array ret = Array.CreateInstance(t.GetElementType(), _valArr.Length);
Array.ConvertAll(_valArr, delegate(object o) { return Convert.ChangeType(o, t.GetElementType()); }).CopyTo(ret, 0);
return ret;
}
return Convert.ChangeType(value, t);
}
Saludos!!
____Juan
|
|
|
|
|
Hi,
Is there any control available in Visual Studio 2008, which i can use to see pdf files in my Win Form Application, somewhat like RTF controls?
Thanks
Karmendra
|
|
|
|
|
|
Is there nothing available form open source or freeware,
I just need to view the pdf file on disk, needs nothing more other than viewing the pdf document, printing, zoom navigate etc are not required.
|
|
|
|
|
Acrobat Reader itself is free to use. In the search results there was an interesting looking article on top: http://www.codeproject.com/KB/cpp/ReaderWrapper.aspx[^]. Perhaps it would help you forward.
Also I believe that there are several other good hits on the results so have a look at them. Adding one keyword more (freeware) to the search gives you about 50,000 hits...
Google is your friend.
|
|
|
|
|
Hi all,
I have added a Northwind dataset to my project by selecting data | add new datasource. Now i can see the the Northwind.sdf and NorthwindDataSet.xsd files on the solution explorer. Question is how can I success to read the rows on the dataset/tables? What is the ConnectionString or do I need it in this case?
I though something like below but the tables.count is always null
DataSet myDataSet = new DataSet("NorthwindDataSet");
foreach (DataRow row in myDataSet.Tables["Customers"].Rows)
{
}
|
|
|
|
|
mhrtg wrote: What is the ConnectionString or do I need it in this case
You can see the connection string in the properties panel when you select your database. However, when with default settings, the database is copied into bin/debug folder when executing your program so the path is different at runtime.
mhrtg wrote: can I success to read the rows on the dataset/tables?
Even though you have added a database into your solution, it behaves like a normal database. So you have steps like:
- get a connection
- fill a dataset with data from db
- close the connection
- use the data in the dataset
|
|
|
|
|
Ok! I got the connection string but opening the connection seems to be a problem. Here is the example
string strConnectionString = "Data Source=C:\\Visual Studio 2008\\Projects\\SampleProgram\\bin\\Debug\\Northwind.sdf"
oconn = new SqlConnection(strConnectionString);
oconn.Open(); <----- error
Northwind.sdf was found from the debug folder
The error message in Finnish:
Palvelinyhteyttä muodostettaessa tapahtui virhe. Kun muodostat yhteyttä SQL Server 2005:een, tämä virhe saattaa johtua siitä, ettei SQL Server oletusarvoisesti salli etäyhteyksiä. (provider: SQL-verkon rajapinnat, error: 26 - Virhe etsittäessä määritettyä palvelinta tai ilmentymää)
|
|
|
|
|
It seems that you're using SQL Server Express Edition or above, not Compact Edition. If this is the case, you could try something like the following for connection string:
"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\\Visual Studio 2008\\Projects\\SampleProgram\\bin\\Debug\\Northwind.sdf;Integrated Security=True;User Instance=True"
The instance name in your local host may not be SQLEXPRESS so change it to a relevant instance name or if you have only default instance you can use just dot (or localhost ).
Also visit: http://www.connectionstrings.com/[^]. It's a great place for resolving connection strings.
By the way, based on your profile you're located in U.S. I'm having doubts on that since I have no difficulties in reading the error text
|
|
|
|
|
Thanks. I will try again later. Now the the location is right
|
|
|
|
|
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.
|
|
|
|