|
this casting is not working
DataRowView drv = (DataRowView)o;
error msg:
Exception Details: System.InvalidCastException: Specified cast is not valid.
|
|
|
|
|
No my fault
If you don't pass a DataRowView, is can not be used as a DataRowView.
Try Console.WriteLine(o.GetType()); to find out, what is really is.
|
|
|
|
|
Does anyone know how to loop through all icons in an embedded folder and populate an imagelist. As seen below, I have an embedded folder Prud.Library.Icons.State which contains a set of icons. I would like to add all Icons in State to an ImageList regardless of their name.
Does anyone know how this can be done?
Thanks heaps.
Note: string sIconName = "Prud.Library.Icons.State.Icon1.ico";
System.IO.Stream objStream = null;
System.Drawing.Icon[] objIcon;
try
{
/*
* Stream Icon and add to ImageList
*/
objStream = this.GetType().Assembly.GetManifestResourceStream(sIconName);
if (objStream != null)
{
objIcon = new System.Drawing.Icon[1];
objIcon[0] = new Icon(objStream);
}
}
catch (Exception err)
{
throw err;
}
finally
{
/*
* Dispose of Stream Object
*/
if (objStream != null)
{
objStream.Flush();
objStream = null;
}
}
return objIcon;
|
|
|
|
|
I know this is a tough one, but any help would be greatly appreciated.
Thanks in advance.
|
|
|
|
|
is there a way to have the microsoft agent character ask a user questions, and when they click yes/ok do one thing and no/cancel do another?
|
|
|
|
|
Hi,
Is there any way i can read remote machine registry in c#.
I will appreciate if some one give me code to read remote machine registry.
Regards,
Waqar.
|
|
|
|
|
You can read from a remote registry using the following static method:
Microsoft.Win32.RegistryKey.OpenRemoteBaseKey(...)
However, according to the MSDN documentation, the following must be ensured:
In order for a key to be opened remotely, both machines (the service, and client) must be running the remote registry service, and have remote administration enabled.
Cheers,
Miahrugger
|
|
|
|
|
You also only have access to the HKEY_LOCAL_MACHINE and HKEY_USERS keys
|
|
|
|
|
Hello,
are .NET form based desktop applications executable on other platforms with .NET framework installed? for example Linux
Thank you
|
|
|
|
|
|
How does this compare with Mono?
|
|
|
|
|
Tell me if you know. Thanx in advance. If not, which control can display both image and HTML code correctly?
|
|
|
|
|
1) No.
2) Any web browser control : Mozilla ActiveX, IE ActiveX, ...
RSS feed
|
|
|
|
|
Thanx u very much
|
|
|
|
|
Subject says it all. Can a function return an array of delegates?
|
|
|
|
|
public class Test {
public delegate void DelegateExample(string[] args);
public static DelegateExample[] GetDelegates() {
return new DelegateExample[] {
new DelegateExample(Test.Main),
new DelegateExample(Test.Main)
};
}
public static void Main(string[] args) {}
}
Regards,
Jeff Varszegi
|
|
|
|
|
Or even better look at delegate.GetInvocationList()
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
Thanks
How would I use that with a function though?
|
|
|
|
|
I need to know how to disable the user's ability to add new rows to the DataGrid based on a DataTable. I have a table that represents options that can be checked on and off with a boolean column. It is a static list of options, so the user shouldn't be able to add new rows. The only thing in the table that is not read-only is the true/false value of the boolean column. I hope I am just overlooking some obvious setting in the TableStyle (I am programmatically creating the style). Any help would be greatly appreciated. Thanks.
|
|
|
|
|
DataGrid doesn't have such an option, neither DataTable. But DataView has:
AllowNew, plus AllowEdit and AllowDelete. The simpliest way is to set as DataSource of the DataGrid a DataView of your DataTable, and set AllowNew =false.
If you can't set as DataSource a DataView (and DataSource is a DataTable), then you still have a chance , since the data grid actually uses the DefautView of a DataTable . So, you can do something like MyTable.DefaultView.AllowNew=false;
If your DataSource is a DataSet then you can do something like this:
CurrencyManager cm =(CurrencyManager)BindingContext[MyDataGrid.DataSource,MyDataGrid.DataMember]
// Cast the IList to a DataView to set the AllowNew property.
DataView dv = (DataView) cm.List;
dv.AllowNew = false;
Best Regards,
Daniel Zaharia
|
|
|
|
|
Thanks that did the trick. I used...
myTable.DefaultView.AllowNew = false;
|
|
|
|
|
I am trying to find a way to take records from a ListView control and move them to the system clipboard so they can be pasted directly into Microsoft Excel.
I have found the DataFormat class and see it supports a CommaSeparatedValue format, but I cannot get it to work correctly.
I have tried this, just as a test...
string s = "1,2,3,4,5,6,7,8,9";
DataObject d = new DataObject();
d.SetData(DataFormats.CommaSeparatedValue,s);
Clipboard.SetDataObject(d,false);
But when I paste it into Excel I get
–§žý;pC¦yVk²ˆû
Have any of you ever successfully formatted data, stored it in the Clipboard so it could be successfully pasted into Excel?
Darryl Borden
Principal IT Analyst
darryl.borden@elpaso.com
|
|
|
|
|
The Comma-Delimited Value isn't a string - which is the confusing part. The following code will do what you want.
// Place comma-delimited on clipboard
string commaText = "1,2,3,4,5,6,7,8,9";
byte[] bytes = System.Text.Encoding.UTF8.GetBytes(commaText);
MemoryStream stream = new MemoryStream(bytes);
DataObject dataObject = new DataObject();
dataObject.SetData(DataFormats.CommaSeparatedValue, stream);
Clipboard.SetDataObject(dataObject, true);
// Read comma-delimited from clipboard
string values=string.Empty;
IDataObject dataObject = Clipboard.GetDataObject();
if(dataObject.GetDataPresent(DataFormats.CommaSeparatedValue))
{
StreamReader streamReader = new StreamReader((Stream) dataObject.GetData(DataFormats.CommaSeparatedValue));
values = streamReader.ReadToEnd();
streamReader.Close();
}
Console.WriteLine( values );
|
|
|
|
|
I tried out your code and it works great!
I have just two questions...
1) where on earth did you dig this up - I have searched all over the place
2) This pastes a single row into Excel - how to I paste multiple rows?
Thanks so much for your help!
dpb
Darryl Borden
Principal IT Analyst
darryl.borden@elpaso.com
|
|
|
|
|
Never mind on the 2nd question. If I insert a "\n" character in the string then it wraps to the next line in Excel!
"1,2,3,4,5\n6,7,8,9"
Thanks again for your help.
dpb
Darryl Borden
Principal IT Analyst
darryl.borden@elpaso.com
|
|
|
|