|
Instead of handling events on the DataGrid , it's better to handle events on the DataSet if you're using one, or rather the DataTable (s) contained in the DataSet . The DataTable has many events (like RowChanged and RowDeleted ) you can handle. These are fired before or after (depending on which events you use) the underlying data source is updated. The DataGrid itself has no effective means to know when the data source was changed.
If you're not using a DataSet , you can either use appropriate events for the IList or IListSource implementation (like an ArrayList ) if any are exposed, or add events by extending the class or creating your own wrapper class.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hey
I have a listview as a System Controller, that i have implemnted into a client server chat.
this listview is keeping trac of the online users and if thay are blocked or private or Public.
If the user is
private = the bakground on this row is painted blue
Public = the bakground is default(white)
Block = the backgraound is red
Problem:
when i start up the first client and joins it to the server, there is no problem al is woking fine, if i start up a second client and join the server, the first client as adding the user propely with the right background.
But the second client that just loggd on gets a strange update error with the bakgraound colors. It recives the user list and add the users thatwas loggdon before the second client, and in this case its just the first client.
The update error on the ListView in the second client is as following.
The bakground color that shows if the user is private,blockt or public is not painting properly, its only filling half of the rows with the colors, tha only way to get it updated is to move another window over the listvew and then it updates and show the proper colors.
Do you got any ide how i shold update my listview so this problem not accures? its strange that the first client is not getting the update error and only the second client.
//Jimmy
|
|
|
|
|
After adding your ListViewItem s, call ListView.Refresh (inheritted from Control ) to invalidate and repaint the client area. You can also call Invalidate with the bounds of whatever region you want to update, and then call Update . This is better for performance since the whole control would not require repainting.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I have my STGMEDIUM class declared as followed:
[StructLayout(LayoutKind.Sequential)]<br />
public struct STGMEDIUM<br />
{<br />
public TYMED_Flags tymed;
public IntPtr item;
public IntPtr pUnkForRelease;
}
Where item is the item reffered to in the union. Now, generaly from experience i've never encountered an IntPtr that isn't exactly 7 in length (well, one that works).
However, when I call the GetData method of IDataObject, i get a 9 digit pointer, that does not provide me with any strings that are actualy on the clipboard.
I'm not sure, but i think i might be getting some value... uhm... over run? Where some of the numbers are taken from the previous / next item in the list.
If I copy a char string to clipboard, i get back a 4 char string of unrecognised charachters.
Can anyone see where this is coming from?
Cheers
Cata
Note: This is only obtained when looking up using HGlobal, I can get a valid pointer to IStream interface without problem.
|
|
|
|
|
As I've explained before, and IntPtr is nothing more than a managed pointer. The number of digits is inconseqential. The pointer is a 32-bit memory address so it could have up to 10 digits in the number. How cares? It's still an address.
You have to get the string using the IntPtr . Once again, a string is nothing more than an array of characters, so this address points to the first character. The problem you're probably running into is handling ANSI and Unicode characters incorrectly. If you know the string will be ANSI, use Marshal.PtrToStringAnsi . Use Marshal.PtrToStringUni for Unicode and Marshal.PtrToStringBSTR for BSTRs (wide characters). If the character encoding is platform dependent, use Marshal.PtrToStringAuto . Note that the last will not automatically figure out what character encoding is in use; it will use ANSI for Windows and Unicode for Windows NT.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Yeah, I tried constructing 3 string holders and ran each type of convertion on the returned IntPtr to test it, but I got 3 gibberish results.
It's got me stumped.
Cata
|
|
|
|
|
Sorry Heath, my mistake.
When i pulled the item off the clipboard, i forgot to apply GlobalLock to it. The IntPtr i got from the lock produced a fully valid string. So all is well.
Cata
|
|
|
|
|
I have a Web application which use Web Service.I have built some classes,include property class which define the propeties of a specific object and DataBase Accessing class which is used to operate the DataBase.
The Question is
i don't know where should I place these classes. At the Web application solution or at the Web Service solution.
|
|
|
|
|
If this operartion should happen in server obviously you add it to web service solution and use it there and call it from your web methods. Is that what you mean?
Mazy
"A bank is a place that will lend you money if you can prove that you don't need it." - Bob Hope
|
|
|
|
|
Thanks for your reply.
i am a chinese.Maybe my statement is not clear.
I place the methords which operate DataBase on the Web Service.
but where the property class should i place?
the property class is like this
class Product
{
private int id;
private string name;
.....
}
If i also place them on the Web Service,will it add the burden of Web Service?
|
|
|
|
|
There is nothing to worry about. Just add its namespace to your class and use it there. Then you can call each method or propoerty you want in your web methods.
Mazy
"Man is different from animals in that he speculates, a high risk activity." - Edward Hoagland
|
|
|
|
|
You should probably consider creating three projects/assemblies (depending on whether you're using Visual Studio or not). (1) The client application, whether Win or Web Forms; (2) The data access layer, your Web service app; and, (3) a project/assembly that contains common classes. You would deploy assembly 3 with both your data access layer and your client application.
Michael Flanakin
Web Log
|
|
|
|
|
double a = 212.45 ;
double b = 6795.9 ;
double c = a + b ;
The result of c is 7008.3499999999995. I cannot understand why the result isn't 7008.35. Anyone can explain that to me ?
Thx a lot
|
|
|
|
|
Internal rounding error
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
|
|
|
|
|
What does that mean exactly ?
Do you mean that .NET double type does rounding error ? No exception at all are thrown from framework.
I resolved it using decimal type but I'd like to understand why this rounding error happens with Double .
Thx
N0rthernlights
|
|
|
|
|
The binary representation of fractional numbers is an approximation. Just as the fraction 1/3 must be approximated when represented in a decimal notation. I would pose a question, though. Since the two numbers you are adding have only 5 and 6 digits of significance, why are you expecting more than that when adding the two together. If you round the result to only be 6 significant digits, you will have the correct answer. The double type can only have 17 digits and once you begin operating on them, the accuracy usually falls down to only about 13 or 14 that are correct.
Chris Meech
We're more like a hobbiest in a Home Depot drooling at all the shiny power tools, rather than a craftsman that makes the chair to an exacting level of comfort by measuring the customer's butt. Marc Clifton
VB is like a toolbox, in the hands of a craftsman, you can end up with some amazing stuff, but without the skills to use it right you end up with Homer Simpson's attempt at building a barbeque or his attempt at a Spice rack. Michael P. Butler
|
|
|
|
|
I've run into problems with the same issue before. The only way I could fix the rounding error was:
double c = a + b;
c = Math.Round( c, 2 );
Hope this helps.
|
|
|
|
|
As far as i remember the double is accurate for 12 digits after the comma.
And as Chris Meech mentionned, the internal represntation of fraction is not the same the one for decimals.
Also if you Round your Number to 12 digits of precision (you have 13), you would get exactly 7008.350000000000
|
|
|
|
|
Thx all for your answers . I now understand that internal fraction representation has some special behaviour. I'll use Decimal type because it's much easier to work with it to calculate money values.
|
|
|
|
|
Hi, I want to use resource files to store message box strings. Which I read that I can by defining Name = value pair in text file. like ex > Close = "Really wann quit this application". But now the problem is where should I wirte this text file and then where should I compile Resgen myResource.txt , to create myResource.resource file. Now after doing all this how should I use these Name of string in my application to call resource file. Thanx for ur support.
Inpreet Singh
|
|
|
|
|
As I've been trying to tell you in an old thread, use a ResX file in VS.NET instead and mark it as an embedded resource. Forms and controls already have a hidden ResX file associated with them. You can use .txt files but you'll have to compile them manually - like I also said before - using resgen.exe to the appropriate name (fully-qualified name) and embedding them with the csc.exe compiler using the /res option.
If you use a ResX file, you can centralize/localize more than just string resources, including various structs and classes that have a TypeConverter associated with them.
I also gave you a link to check out that shows MANY examples of using the ResourceManager and even a code snippet, which I'll post again:
ResourceManager resources = new ResourceManager(typeof(SomeClass)); Use the code above is a .resources file would have the same namespace and name (fully-qualified name) as a class. If now, you have to use the name and get the assembly, something like:
ResourceManager resources = new ResourceManager("MyResources.resources",<br />
this.GetType().Assembly);</pre>...where <code>this is an instance of your class that will use the resources. You need to get the Assembly and this is one of many ways to do it (one of the faster ways).
Here's that link[^] again for the ResourceManager class.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hello,
I have a non-rectangular form that I created by overriding the form's paint method and adding the following:
<br />
System.Drawing.Drawing2D.GraphicsPath myGraphicsPath = new System.Drawing.Drawing2D.GraphicsPath();<br />
<br />
myGraphicsPath.AddLine(...);<br />
myGraphicsPath.AddLine(...);<br />
myGraphicsPath.AddLine(...);<br />
<br />
this.Region = new Region(myGraphicsPath);<br />
Now, the form is the shape I want (diamond) but the edges are jagged. Is there any way for the lines to be smoother, so that the edges are not jagged? Is there any method I can use other then AddLine to get a smoother edge?
Thanx for the help,
-Flack
|
|
|
|
|
If u take printscreen of an image which has smoother edge and u see it in a magnified view, u can see some pixel in an intermediate color in between the edges and the background. That pixels make the edges smoother.
You can draw another line in a lighter color around the form border.
I hope it will work.
|
|
|
|
|
What you're looking for is called "antialiasing", where the color used slowly tapers off to the background, rather than being a crisp border.
Run a search for "Antialiasing in GDI+" and you should find plenty of stuff...(don't have my MSDN handy)
Jeremy Kimball
|
|
|
|
|
Hi all,
I am new bee in C#, I want to start an exe and stop it later some time in my C# application, How to do that?? Pl. help me.
Thanks &
Reg,
Satya
|
|
|
|