|
it's just that you only are allowed to change a control within the thread where the control was created...thus you have to call grid.Invoke() like this:
public delegate MyDelegate void GridUpdateMethod( /* here maybe some parameters */);
it's important that the parameters you write above
must be then identical with the method - parameters where you update the grid.
and then you call:
grid.Invoke(new MyDelegate(methodname));
after that you just have to write a method (-> methodname ) where you update the grid.
public void methodname()
{
//here grid update
}
that's all. but I have no clue of COM or COM+....sorry
|
|
|
|
|
Yesterday I was trying to inherit from HttpWebRequest, to implement a protocol that extends HTTP. In the end, I think it is impossible...although the class itself can be inherited from, its main constructor is effectively private (probably declared "internal"), which means that my derived class cannot construct the base class.
This is due to the nature of the HttpWebRequest, which is always created through the WebRequest.Create() method, never directly through its constructor.
Does anyone have any experience with or insight into this?
|
|
|
|
|
How do you want to extend HTTP? If you want to add headers, you can add them to the Headers collection. If you want to use a custom verb, you can do that too: set the Method property.
If you want to customise these properties in a fixed way, and still plug in to WebRequest.Create , I think you'll have to derive a new class from WebRequest , have an HttpWebRequest as a member, and forward methods to your HttpWebRequest .
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
You are right, I can add to the headers, and set the Method property. That is what I ended up doing. And it is a simpler design this way, so everything worked out for the best (so far at least).
However, I found it strange that MS would create a non-sealed class that could not be inherited. A sealed class is faster after all...and I would think that they would want the framework to be as efficient as possible.
So I figured it may just be that there is some technique that I am unaware of - I'm still a C# newbie in many ways . I'd still like to be able to inherit from it if the design evolves that way. Decorating objects (your 2nd suggestion) is usually a last resort for me, as it is always so repetitive.
[Since you asked, I am writing a 100% managed C# component for working with the client side of WebDAV. (Yes, I know that I can use MSXML). WebDAV is an extension to HTML, so it shares all the same basic characteristics. Extension equates well to inheritance, so that's why my first thought was to inherit from HttpWebRequest .]
|
|
|
|
|
The reason it cannot be inherited is because HttpWebRequest does not have a public default constructor that takes zero arguments. If you use code like this (note: not safe, you must provide proper arguments for base(..,..) ) it will compile and work:
public class SafeHttpWebRequest : HttpWebRequest
{
public SafeHttpWebRequest() : base(null, new StreamingContext()) { }
}
|
|
|
|
|
Hello ya'll,
This is my first posting so i'm not sure whether anyone out there can help me and whether or not i have picked the right forum. I'm using the .NET framework to create an application on the PDA. I'm stuck at a point where i have utilised the RDA (Remote Data Access) method and successfully "Pulled" the table "Employees" from Northwind database stored locally on my machine on SQL Server 2000. Now, the thing is i can see the tables in my PDA when i check the directory where i created the database that would incorporate "Employees" in. Now, i can't seem to actually modify this! i've used this:
Globals.conn = null;
Globals.conn = new SqlCeConnection ("Data Source = wta.sdf");
Globals.conn.Open();
Globals.cmd = Globals.conn.CreateCommand ();
Globals.cmd.CommandText = "INSERT INTO Employees (EmployeeID, LastName, FirstName) VALUES (1, 'Smith', 'Bob')";
Globals.cmd.ExecuteNonQuery();
it keeps throwing up "A duplicate value cannot be inserted into a unique index". In that case, what's the point of being able to pull the database if i can't even modify it or use it at all? Please help me... i've gone through tooo many stress balls
|
|
|
|
|
I suspect there's already an employee in the Employees table with an EmployeeID of 1, and there's a unique index on this column.
With a bit of luck, EmployeeID is an IDENTITY column and you should simply not supply a value for that column:
INSERT INTO Employees (LastName, FirstName) VALUES ('Smith', 'Bob') It's certainly an IDENTITY column in the version supplied with SQL Server 2000. I assume that these parts of the schema are synchronised with SQL Server CE.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Thanks dude!
You are right, it was a problem with the EmployeeID being a unique index, and it being a primary key. So, i fixed it up and also did some stuff and came up with this:
Globals.conn = null;
Globals.conn = new SqlCeConnection ("Data Source = wta.sdf");
Globals.conn.Open();
//The connection is now open and now we're going to view what we've
//pulled out from the database
Globals.cmd = Globals.conn.CreateCommand();
//This would select the LastName segment of Northwind
Globals.cmd.CommandText = "SELECT * FROM Employees";
//This would then be executed and displayed on the MessageBox
Globals.rdr = Globals.cmd.ExecuteReader();
Globals.rdr.Read();
MessageBox.Show("ID Number: " + Globals.rdr.GetInt32(0).ToString() + " " + "Last Name:" + Globals.rdr.GetString(3));
Globals.cmd.CommandText = "UPDATE Employees SET LastName = 'Smith' WHERE EmployeeID = 1";
Globals.cmd.ExecuteNonQuery();
This worked perfectly, because i'm not actually changing the EmployeeID, i'm just updating the columns in reference to the primary id. Thanks dude!
|
|
|
|
|
Hi,
for an application written in C# it would be nice to have the Debug or Trace Messages shown in a textbox on a windows form.
Is it possible to redirect these messages from the standard output to , lets say to a textbox, listbox whatever?
thanks in advance
Jörg
|
|
|
|
|
Create a class derived from System.Diagnostics.TraceListener and override the Write(string) and WriteLine(string) methods. Then add an instance of this class to the Trace.Listeners and Debug.Listeners collections.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
There are also some built in TraceListeners. I often write console front-ends that listen for Trace messages and output them to the console. Its really simple:
Trace.Listeners.Add(new TextWriterTraceListener(System.Console.Out));
Probably not that useful for working with WinForms, but still a great tip
|
|
|
|
|
thanks, working fine! Very helpful....
Jörg
|
|
|
|
|
Hi,
Has anyone tried using iButtons on .NET?
I cant seem to make it work.
I tried Creating a Runtime Callable Wrapper out of the COM component, using tlbimp.exe
and then referenced it in the project.
I noticed that all the methods return Object type and not what they are supposed to.
For example:
OneWireAccessProvider provider = new OneWireAccessProvider();
DSPortAdapter adapter = provider.getDefaultAdapter();
getDefaultAdapter() returns an Object and not a DSPortAdapter as it was supposed to.
Casting it doesn’t work.
I also tried referencing OneWireAPI.dll,
everything compiles right but when running :
DSPortAdapter adapter = OneWireAccessProvider.getDefaultAdapter();
I get An unhandled exception of type 'java.lang.UnsatisfiedLinkError' occurred in vjslib.dll
Please anyone ?
|
|
|
|
|
I have a Windows Application written in VB.Net that needs a face lift. I've created a button console VERY similar to the one in Microsoft Windows Media Player, but I'm having problems creating the Windows Forms buttons. I have all the images, but dont know how to make create round buttons in VS.Net. The built in button controls seem to only support square or rectangular shaped buttons. Does anyone know of any samples or have any advice on how to accomplish this? Any help would be appreciated!
Anthony S. Kilhoffer
"Work like a slave, create like a god!"
|
|
|
|
|
if you want to write controls with non-rectangular
shapes you can do it like this
for example:
Button bu = new Button();
GraphicsPath gp = new GraphicsPath();
//here you can add any shapes you want
gp.AddEllipse(0,0,300,300);
bu.Region = new Region(gp);
with the Region-property of the button you set the button to the non-rectangular shape you have created with the GraphicsPath instance.
|
|
|
|
|
I can record a phone call via the soundcard using the class's found in
Microsoft.DirectX.DirectSound, but cant figure out how to display the
recording levels while the call is happening (like the Sound Recorder
app found in Windows).
Any one have any idea on how to do this?
Thanks in advance for any help.
|
|
|
|
|
I have tried in a program to serialize the PrinterSettings class using the BinaryFormatter but an error come up saying that tristate is not serializable even if the PrinterSettings class is serializable.Does anybody know how can i overcome this problem
Thanks in advance
From Greece:
Dimitris Iliopoulos
dimilio@yahoo.com
|
|
|
|
|
You can write your own your custom class and store printer setting in it and serialize it.
Mazy
"I think that only daring speculation can lead us further and not accumulation of facts." - Albert Einstein
|
|
|
|
|
I need functionality that check that one type can be cast explicitly to another. I want to note that need explicit cast not convertion in mean of Convert ot TypeConvert classes. So I need the follow function:
bool CanCast(Type sourceType, Type destType)
{
....
}
and another
object Cast(object val, Type castType)
{
...
}
Anybody have idea how this can be done?
|
|
|
|
|
You're in luck, there is already a method in the framework that does that.
bool CanCast(Type sourceType, Type destType)
{
return destType.IsAssignableFrom(sourceType);
}
not sure what you want to do in the second method because an "object" is a type that ANY object in the framework and in your own class libraries can be casted to. Basically it is pointless to try to cast object type parameter 'val' to the 'castType' and then return an 'object' again. If you wanted to "create" and object of a type that is only known at runtime you can use the Activator class methods to do that.
|
|
|
|
|
IsAssignableFrom work for inheritance but not for explicit or implicit cast. About second method maybe you are right, but I'm not sure that there will have no preblems if I work with boxed long instead of int, if int is required (like parameter value for SQLCommand as example).
So I want to check if object from some type can be safly casted to another type. I have tried to find what cast operators the type have but have not found anyway to do that. Maybe there is some method like Type.GetMembers() that return all cast opertors for specific reflected type? (GetMembers() do not return cast operators)
|
|
|
|
|
Well you can always enclose the casts that are important in a try...catch block and catch the InvalidCastException. I mean using exceptions to control a program flow is not a good programming practice, but I don't see another way to do it at runtime. What are you going to be casting? Something like this:
object someExternValue = ... get this value ...;
int param = (int) someExternValue;
If you are doing it like that, you can use the Convert.GetTypeCode method to get a TypeCode of an 'object' variable. So
TypeCode tc = Convert.GetTypeCode(someExternValue);
if (tc != TypeCode.Int32)
{
.. ok to cast to int ..
} else {
.. not ok ...
}
hope this helps
|
|
|
|
|
Hi everybody,
What do you think? What is better choice: Dundas Ultimate Toolbox or Dundas Chart for ASP.NET???
thanks in advance
|
|
|
|
|
That is like asking "Which is better: a washing machine or a fridge?"
If you are going to be drawing charts in ASP.NET then go for Dundas Chart. If you are going to be developing Windows applications using MFC go for Dundas Ultimate Toolbox.
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
|
|
|
|
|
Hi Colin,
I'm going to be developing both(charts in ASP.NET, Win. App. with MFC). I would like know your opinion which one is more useful?
|
|
|
|