|
Not easily, no. For that you really have to understand the Windows messaging system, styles, P/Invoke in .NET to use all that, and dialog resources in Win32.
I would suggest re-designing your controls. You could, for example, use a UserControl or some other Control derivative and just dock it (using DockStyle.Fill ). If the UI and implementation is already in a form, then abstract them to a UserCotrol (or something) and use that in both forms.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi all,
I'd just like the souce code to get a timestamp from a terminal.
example program:
standard form, with a command button on it. When you click the button, it gets the time from the terminal and displays it on the form!
I just need the code behind the button
Thanx 4 your help
|
|
|
|
|
Stuggo wrote:
gets the time from the terminal
What do you mean by "terminal"?
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
My Blog
|
|
|
|
|
Hi people, hope you can help me.
I have the following code
public class TestDS : System.Data.DataSet
{
}
public class DataSupplier : dalBase
{
public DataSet GetSupplierList()
{
HybridDictionary parms = new HybridDictionary();
return Factory.GetDataSet("GetSupplierList", parms);
}
public TestDS GetSupplierList()
{
HybridDictionary parms = new HybridDictionary();
return (TestDS)Factory.GetDataSet("GetSupplierList", parms);
}
}
The first method works fine and returns a normal dataset. However, I need to create a strongly typed dataset hence the casting in the 2nd method to my own subclassed dataset. Trouble is when I run this I get a the dreaded 'Specified cast is not valid' error.
I was sure that I should be able to do this but it just doesn't work. Any ideas anyone?
Cheers
Paul
|
|
|
|
|
First, it is not CLS-compliant to have more than one method with the same name that differs only by the return type. Instead, rename one or both of your methods, such as GetTestSupplierList or something more suitable.
Second, your DataAdapter (or however you're filling your TestDS ) should actually fill an instance of that TestDS class. So, perhaps add a Type parameter to your Factory.GetDataSet method, something like this:
public static DataSet GetDataSet(string storedProc, IDictionary parms, Type dsType)
{
if (dsType != typeof(DataSet) || dsType.BaseType != typeof(DataSet))
throw new ArgumentException("Not a valid DataSet type.", "dsType");
DataSet ds = (DataSet)Activator.CreateInstance(dsType);
} You should be able to cast it, since the return of GetDataSet still returns a DataSet . Such a method works fine in our enterprise application.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
My first C# development at work needs to connect to a unix box and transfer files (both directions) using SSH (secure shell) and SCP (secure copy). Can anyone recommend a product/component/code to do this? I've come across Putty and SSHActiveX etc but I'd like a .NET solution if at all possible. Thanks.
Gavin
|
|
|
|
|
IP*Works![^] has such products for several different platforms including .NET.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
hi,
i wanna set one of the columns to be read only,
i use DataGridColumnStyle and set the read only property to true, but i still can edit the table, how to solve this?
thanks
|
|
|
|
|
|
I bind a arraylist to a datagrid which works fine. However when I modify data directly in the datagrid it isn't updated automatically to the ArrayList.
QUESTION
How can I force that a modification/update to a datagrid field will update the ArrayList immediately?
Regards,
Uyen Chi
|
|
|
|
|
Data is committed when the column is committed. This is the way that the DataGrid works. There have been many discussions about this in this forum before if you care to search. Just click "Search comments" directly above the message board.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Please look at the snippet
-----------------------------------
1 RichTextBox rtf = new RichTextBox();
2 Bitmap img = new Bitmap(@"c:\myImage.bmp))
3 Clipboard.SetDataObject(img);
4 rtf.Paste();
------------------------------------
when the program control passes line number 3 and if I copy some other text/image in the Clipboard using "Control + C", the earlier image 'img' gets vanished. Is there any way to lock the clipboard for other operations till I paste the image 'img' in RichTextBox?
Please Guide
|
|
|
|
|
|
Can the use of GlobalLock solve the purpose?
If yes, then how to use it in C#? how to get Handle to Clipboard ?
please guide
|
|
|
|
|
No, because the clipboard contains pointers to objects. All GlobalLock would do (and you'd P/Invoke that like anything else, using GCHandle to pin reference types in memory) is lock your object to prevent it from being overwritten.
The problem you're facing is a problem that all application face. Either use a clipboard ring like Office has (and manage that yourself - ever so carefully) or learn to deal with the consequences as every other application does.
The best way is to avoid using the clipboard when you don't need it. Marshal objects to other processes and what not when possible.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi all,
I have just moved some Enumerations from one assembly to a new one. However, the solution no-longer builds, as the enum's have suddenly become non CLS-Compliant. Moving them back to the old assembly fixes the problem! Is it really the case that you cannot use enum's from different assemblies?
I have google'd for the problem, but the only things I could find said to explicity define the enum as type int, which I have done without success.
Any ideas?
Thanks in advance,
Simon.
|
|
|
|
|
Simon_uk wrote:
Is it really the case that you cannot use enum's from different assemblies?
I use enums from different assemblies all the time. In fact you probably do too when ever you use an enum from the Framework itself.
Can you post the exact error message? It might help narrow the problem.
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
My Blog
|
|
|
|
|
Thanks for your response.
Colin Angus Mackay wrote:
I use enums from different assemblies all the time. In fact you probably do too when ever you use an enum from the Framework itself.
Yes, I realise this, which is what makes it even stranger (to me anyway!).
Ok, to recreate this problem create a new solution and add two new projects (I added a class library (proj1) and a windows control library(proj2)). I added a new file to proj1, which contained the following enum definition:
<br />
public enum MyEnum<br />
{<br />
Monday,<br />
Tuesday,<br />
Wednesday<br />
}<br />
In UserControl1 in proj2, I added a new property of Type MyEnum. This builds successfully. I then added the line:
<br />
[assembly: CLSCompliant(true)]<br />
to the AssemblyInfo.cs file (and added using System;)
Now re-building gives this error: "c:\Working\testenum\controls\UserControl1.cs(43): Type of 'controls.UserControl1.Day' is not CLS-compliant".
Any clues?
Thanks again for your help,
Simon.
|
|
|
|
|
Did you add the line: [assembly: CLSCompliant(true)] to both projects?
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
My Blog
|
|
|
|
|
No, I thought I had tried that, but obviously not because it now works!! Thanks very much for your help - most appreciated!
Cheers.
|
|
|
|
|
Is there any way in .NET to get machine constants (I need to build an application licensing software). If not, how far can I get by using only managed code?
Thanks,
Daniel
|
|
|
|
|
Don't know exactly what you mean by machine constants, but I think maybe the Environment class could be helphful.
Take a look at the documentation[^].
www.troschuetz.de
|
|
|
|
|
things like HDD serial number, processor serial number, etc.
I’ve almost forgotten… it must work on Win 98 as well
|
|
|
|
|
Mmh, I'm pretty sure there is no easy way to get this with managed code.
Sorry, maybe someone else can help!
www.troschuetz.de
|
|
|
|
|
your wrong foo!
/\ |_ E X E GG
|
|
|
|