|
You can use graphics.ScaleTransform() to do the zoom and graphics.TranslateTransform() to reposition on specific part of your drawing surface. You have to make those call to graphics before any drawing occurs. To make the zoom 200% you do graphics.ScaleTransform(2.0, 2.0)
You can lookup more documentation on this at graphics class.
|
|
|
|
|
Does the VC#.net package on market contains the compact framework
so I don't need to buy the whole VS studio .net for programming CE
device ? The two packages are different a lot in price.
Thanks
|
|
|
|
|
|
Hi!
I am developing a web application in asp.net using C#. my problem is that i take user input and store it into database. Now when i take the input for "salary". from a text box i am unable to convert it into "Money data type".
my code is
string sql="insert into User1 values ("+txtUser_ID.value+", .... ... ','Cast('txtSalart.value' as Money)','.....
I hav tried several other combinations as well but each time i get the errors like
1. Invalid character near txtSalary,
2. Can not convert to Money from varchar Use CONVERT function
anf bla bla....
Similarly what should i do to store date without a time value. ie i just want to store date n not time. and also i want to retrieve only date value and not time....
Can any one help me out ???
Waititng 4 reply
|
|
|
|
|
To convert to money data type you can use:
decimal amount = Convert.ToDecimal(txtSalary.value)
then you can use amount.
Best way to do that would be to use parameterized query instead of creating sql as string.
cmd.Text = "insert into user1 values (@col1, @col2)";
cmd.Parameters.Add("@col1", txtUserID.value); // if it's a string
cmd.Parameters.Add("@col2", amount);
|
|
|
|
|
To get the date only part of datetime you use Date property.
DateTime someDate = ...;
DateTime dateOnly = someDate.Date;
|
|
|
|
|
Hy folks,
well, the subject says it all, how can I turn off/mute the system audio output? Probably some DLL call ? (Could it be user32.dll?).
Thanks in advance!
|
|
|
|
|
This[^] article should give you a start. See the Platform SDK on MSDN Library[^] for more information about mixer control types (like
MIXERCONTROL_CONTROLTYPE_MUTE <br />
Microsoft MVP, Visual C#<br />
<a href="http://www.codeproject.com/script/articles/list_articles.asp?userid=46969">My Articles</a>
|
|
|
|
|
How can it be used?
The only thing I can do is retrieve the colors in the Entries.
How can I change them?
I'd like to change the palette of a 256 color gif.
So I have Bitmap MyBitmap = new Bitmap("file.gif");
I tried MyBitmap.Palette.Entries[0] = Drawing.Color.Black, but it does nothing as Entries is a read only properties.
How can I change the palette entries? Or how can I create a new ColorPalette?
Bitmap.Palette is a read / write property, but there is no constructor for the ColorPalette class, and the ColorPalette.Entries are read only
|
|
|
|
|
ColorPalette is a value-type. You can change a value of it when it's a property of another type. For more information about value types vs. reference types, see http://www.albahari.com/value%20vs%20reference%20types.html[^].
In order to change the palette, you must first get a copy of the ColorPalette struct:
ColorPalette palette = img.Palette;
palette.Entries[0] = Color.Red;
img.Palette = palette;
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I have an application that populates a PictureBox control with an Image and then dynamically adds controls to the form on the top of the PictureBox . The PictureBox is the Container of all the dynamic controls. The problem I have is disposing of these dynamic controls. When I run the following code it dosposes of some of the dynamic controls but not all of them:
foreach (Control control in this.pictureBox1.Controls)<br />
{<br />
this.pictureBox1.Controls.Remove (control);<br />
control.Dispose ();<br />
}
Any ideas why it doesn't get rid of them all?
When they were created they were all added to the pictureBox1.Cotrols collection.
|
|
|
|
|
Hello,
How do you remove Remove text selection in an RTB, (i.e. So you can't select the text in the RTB) RTB = RichTextBox
regards,
Gobbatroll.
|
|
|
|
|
can media player develop in VC change in C#?
OR
can develop media player in C#?
sdfsdfsdfhsdfh
|
|
|
|
|
you can find C# sample programs to play audio and video files in the Managed Directx 9 SDK
|
|
|
|
|
Hi,
I would like to dynamically list all bitmaps of one folder (with thumbnail) on listView control.
The idea is that when user select/change the folder, the program will auto search every existing bitmaps from the folder, and try to list them on listview control.
Now, I got 2 question,
1. How can I tell ListView to draw item from customerDraw, but I couldn't find this property.
2. Or I need to create ImageList dynamically, and then list them.
Could anyone give me some ideas , and better provide me some examples
Thousand thanks
|
|
|
|
|
It would be easier to inherit from ListBox and do your own custom drawing there.
You set DrawMode to DrawMode.OwnerDrawVariable (if you want to draw the bitmaps in different sizes). Then you override OnMeasureItem and OnDrawItem to do the painting.
You should create a property for your new listbox called Directory. When value is set for this property you populate private arraylist with all bitmaps in that directory. To do that you can use: System.IO.Directory.GetFiles(myDirectory, "*.bmp")
During measure item and drawitem you just draw those bitmaps.
|
|
|
|
|
string[] sA;
How to change sA size (Length)
Thank You.
|
|
|
|
|
You set the array length when you "new" the type. As is the array has no size yet.
|
|
|
|
|
The initial size is set at creation time:
sA = new string[5];
If you want to change the size later, you have to create a new array and copy the content of the old one:
string[] sB = new string[8];<br />
Array.Copy( sA, 0, sB, 0, sA.Length );<br />
sA = sB;
|
|
|
|
|
You can alsow store your data in System.Collections.ArrayList
that how you don0t need to specify a size, and size can be chaneg during runtime without copying the contents to another array.
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
The answer is, you cannot change the size of an initialized array.
The amount of storage space designated at initialization time is not changeable without destroying the original Array object. For example, the String type (basically a Char[]) is considered immutable; that is, you cannot truly change a String variable, you can only destroy it and assign a new value to the same variable name (that's why StringBuilder is such an efficiency improvement over string concatenation...under the covers it uses a collection type that's sizable until you ask for the ToString() representation).
That said, I saw someone posted a method to copy one Array into another (presumably larger) Array, and someone else has suggested the ArrayList class. There are numerous other classes available (StringCollection to name one), or you can make your own. A good place to start is CollectionBase or DictionaryBase, depending on whether you want straight values or key-value pairs.
Hope this helps.
|
|
|
|
|
Hi, I had a problem with socket permission.
I have created a server that has leaves its port opened to clients and telnet applications.
Clients can run succesfully if they stay in the same machine (localhost). Telnet on local host to the server port can be connected too.
However, if I tried to connect to the server port from another machine in the intranet, I won't be able to connect.
I've tried many ways, I've set the trust region of intranet to full trust, I've made instances of SocketPermission:
SocketPermission mySocketPermission1 = new SocketPermission(PermissionState.Unrestricted);
SocketPermission mySocketPermission = new SocketPermission(NetworkAccess.Accept, TransportType.Tcp, "192.168.*.*", SocketPermission.AllPorts);
But, why can't remote clients (hyperterminals / telnet) connect?
For your information, I'm using asynchronous sockets for my server application. Is the problem related with the socket permission, or is there any other possible problems, i.e. wrong class library usage. Thanks.
|
|
|
|
|
You are given tow rectangles each defined by an upper left(UL) corner and a lower right(LR) corner.Both rectangles' edges will always be parallel to the x or y axis as shown in Figure 7.2.Write a window program that use mouse to draw the rectangle add the program will determines wether the two rectangles overlap.For convenience.You may use the following structs:
Struct point{
Int x;
Int y;
}
Struct rect{
struct point UL;
struct point LR;
}
The function prototype is As following:
Int overlap(struct rect A,struct rect B):
Please help me to finlish the question,thanks.
|
|
|
|
|
(struct rect A,struct rect B):
Remember that this is the C# forum
Let .NET do it for you...
bool overlap(Rectangle a, Rectangle b){
return a.IntersectsWith(b);
}
|
|
|
|
|
In the Component Services Administrative Tool,we can see the satatus of components activation. Like this,I wonder if i can implement this kind of functionality as using C# Language.
Please,help me.....Any idea will be helpful...
|
|
|
|