|
hi all,
I need to Color Tool Bar and need to add Blue water mark for buttons when mouse on the Tool Bar Buttons?.
How do I suceed this?.
thanks in advance.
|
|
|
|
|
Hello everybody!
I want to print a document out with A4 paper size programmatically. But I don't know how to define the precise paper size in C#. And also, if I don't use the form's location, how can I locate a particular position of the paper? Could anybody help me with this please!
Thanks in advance
Asura
|
|
|
|
|
This is what I gathered from MSDN in a few minutes:
Choose one of the page sizes from PrinterSettings.PaperSizes collection and put it in the PageSettings.PaperSize property.
---
b { font-weight: normal; }
|
|
|
|
|
Ming Luo wrote:
I want to print a document out with A4 paper size programmatically.
The prefered method is to allow the user to select the paper size since their needs may change after the application is released. To do this, implement a PageSetupDialog. If A4 is the default paper size for the printer, it will already be set in the dialog. If it is not the default size, I believe you could create a PaperSize object, set it to a PaperKind of A4 in PageSettings before printing (or showing the PageSetupDialog). Check the MSDN documentation on PageSettings[^] and PaperKind Enumeration[^].
To implement PageSetupDialog, you can use this code snip from the MSDN article[^] on PageSetupDialog Class in a print button handler. (Note this code assumes a ListBox named ListBox1 that will display the settings (used to indicate how to get the values after the user clicks OK in the dialog) and a PageSetupDialog named PageSetupDialog1.
PageSetupDialog1.PageSettings = <br />
new System.Drawing.Printing.PageSettings();<br />
<br />
PageSetupDialog1.PrinterSettings = <br />
new System.Drawing.Printing.PrinterSettings();<br />
<br />
PageSetupDialog1.ShowNetwork = false;<br />
<br />
DialogResult result = PageSetupDialog1.ShowDialog();<br />
<br />
if ( result == DialogResult.OK)<br />
{<br />
object[] results = new object[]{ <br />
PageSetupDialog1.PageSettings.Margins, <br />
PageSetupDialog1.PageSettings.PaperSize, <br />
PageSetupDialog1.PageSettings.Landscape, <br />
PageSetupDialog1.PrinterSettings.PrinterName, <br />
PageSetupDialog1.PrinterSettings.PrintRange};<br />
ListBox1.Items.AddRange(results);<br />
}
If this doesn't work for you or give you enough clues, post back and let us know.
Marshall
If you continue to do the same things you always did, don't be surprised if you get the same results you always got.
|
|
|
|
|
Thanks for your code. But I think what I need is to define the paper size programmatically before the page dialog. Because there is a form need to be filled. For example, if give me a check, I need to fill in the address and customer name information in it, so I need to define the precise position of the address row and customer row in the check, then I put the check into the printer, it will print it. Just like the teller does. Actually it's not a check, what I am doing is a invoice which is A4 size. So another problem is that how can I define the location of the field I need to fill in my program??? Any idea please ?
Thanks very much
Asura
|
|
|
|
|
Ming Luo wrote:
how can I define the location of the field
There are many options. Try this CP article on DaReport PrintDocument[^] to see one approach at positioning objects (including text) on a printed document such as a check. It is not the most straight-forward approach but it is clever and extensible.
Marshall
If you continue to do the same things you always did, don't be surprised if you get the same results you always got.
|
|
|
|
|
Check Out This Code:
PageSetupDialog psd= new PageSetupDialog();
psd.PageSettings.PaperSize = psd.PrinterSettings.PaperSizes[ 4 ]; // 4 denotes the paper index you pass different index and check the Paper size. On my printer paper sizes A4 exits on 4 index.
Try this then tell me.
Muhammad Waqas Butt
waqasb4all@yahoo.com:
Muhamad Waqas Butt
waqasb4all@yahoo.com
|
|
|
|
|
Hello gurus,
I'd like to know how to detect which child has been activated in an MDI?
The MdiChildActivate does not show me which child window has been activated, or maybe there is a cast to do somewhere in the code handler...
Best regards.
Fred.
There is no spoon.
|
|
|
|
|
Although I must admit that I didn't work with MDI much, I'd expect the sender parameter to be the MdiChild that's being activated.
Did you check this?
Regards,
mav
|
|
|
|
|
you're right, I'm not familiar with MDIs...
I mainly do dialogs :P
Thanks
fred.
There is no spoon.
|
|
|
|
|
I'm writing a function as below:
public string returnString()
{
try
{
//open connections
return var1;
}
catch (Exception ex)
{
//write to trace
}
finally
{
//close connections
}
}
I'm getting an error that says the function will not return a value in some execution.
Where should I return the value? After finally?
|
|
|
|
|
If your try fails, it will jump to the catch block. There is no return statement in the catch block therefore, once the error is handled it does not know what to return out of the method.
You either need an additional return in the catch block or you need to return something after the finally block.
My: Blog | Photos
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
|
|
|
|
|
For example, if I am retrieving data from a DB and returning the dataset. An exception occurs and no data is retrieved.
In this case, should I still return the dataset in the catch block\after finally?
My initial thought was that I wouldn't return anything if an exception occurs.
|
|
|
|
|
|
I see!
Thanks very much Colin!
Regards,
Os
|
|
|
|
|
Hi
Can the backcolor of a specific row in datagrid be set. I want to compare the values in an arraylist against the values in the datagrid and if a match is found I want to change the backcolor of that row so that the user can easily see the matches.
On that point can the backcolor of all the rows in the datagrid be reset to White in one property or do I need to loop through the datagrid and set each row's backcolor to White.
Thanks
Kobus
|
|
|
|
|
public class DataGridColoredTextBoxColumn : DataGridTextBoxColumn
{
protected override void Paint(System.Drawing.Graphics g,
System.Drawing.Rectangle bounds, System.Windows.Forms.CurrencyManager
source, int rowNum, System.Drawing.Brush backBrush, System.Drawing.Brush
foreBrush, bool alignToRight)
{
// the idea is to conditionally set the foreBrush and/or backbrush
// depending upon some crireria on the cell value
// Here, we color anything that begins with a letter higher than 'F'
try{
object o = this.GetColumnValueAtRow(source, rowNum);
if( o!= null)
{
char c = ((string)o)[0];
if( c > 'F')
{
// could be as simple as
// backBrush = new SolidBrush(Color.Pink);
// or something fancier...
backBrush = new LinearGradientBrush(bounds,
Color.FromArgb(255, 200, 200),
Color.FromArgb(128, 20, 20),
LinearGradientMode.BackwardDiagonal);
foreBrush = new SolidBrush(Color.White);
}
}
}
catch(Exception ex){ /* empty catch */ }
finally{
// make sure the base class gets called to do the drawing with
// the possibly changed brushes
base.Paint(g, bounds, source, rowNum, backBrush, foreBrush, alignToRight);
}
}
}
Live Life King Size
Alomgir Miah
|
|
|
|
|
Hello every body
i need ur help.
plz any body sendme the code in c# tha connect the webcam and then extract frames and save it into my local drive,
i realy thankful to that person.
waiting
best regards
abdullah
abd
|
|
|
|
|
search for webcam in the search bar of cp & u,ll find many things
The C Lover ..
|
|
|
|
|
How can I find out witch color in a Gif image that is transparent?
I'm creating small icons of images in an ASP page, and I'm writing the images to the output stream.
First I'm resizing the image, witch data I get from a memory stream (this data is an transparent image, and in this code example I use PNG to try to get transparency):
<br />
public Bitmap _bitmap = null;<br />
private void getGraphicsFromImageNotStretched(MemoryStream ms, int hight, int width)<br />
{ <br />
Image image = Image.FromStream(ms, true); <br />
<br />
double orgHight = (double)image.Height;<br />
double orgWidth = (double)image.Width;<br />
if((orgHight * hight) > (orgWidth * width))<br />
{<br />
double ratio = (orgWidth * width) / (orgHight * hight);<br />
_bitmap = new Bitmap(image, (int)((double)width * ratio), hight);<br />
_bitmap.Palette = image.Palette; <br />
_bitmap.MakeTransparent();<br />
}<br />
else<br />
{<br />
double ratio = (orgHight * hight) / (orgWidth * width);<br />
_bitmap = new Bitmap(image, width, (int)((double)hight * ratio));<br />
_bitmap.Palette = image.Palette;<br />
_bitmap.MakeTransparent();<br />
} <br />
<br />
image.Dispose(); <br />
}<br />
Then I write the data to the output stream:
<br />
public static byte[] GenerateImageBytes(Bitmap theBitmap)<br />
{<br />
byte[] bytes = null; <br />
<br />
System.IO.MemoryStream ms = new System.IO.MemoryStream();<br />
theBitmap.Save(ms, ImageFormat.Png);<br />
bytes = ms.ToArray();<br />
ms.Close(); <br />
<br />
return bytes;<br />
}<br />
This result in an image that is not treansparent
If anyone has a code-snip or an example to get this working, I'll be happy as a dove.
Thanks
Thomas
|
|
|
|
|
Hi all,
I have tested using ref in passing reference to method,
e.g.
Car car1 = new Car();
Change(ref car);
...
void Change(ref Car car)
{
car.id = 1;
//car = null;
//car = new Car();
}
it seem that by passing car by ref can null the reference of the car,
or change the reference of the car, it can do more that just
by Change(Car car) (i.e. without the ref keyword.
Then why we not always add ref keywords to the method, so
more capabilities are achieved ? What are the disadvantages
of using ref ??
Thanks
|
|
|
|
|
The disadvantages of ref keyword is it can change the reference of car.There is a situation we don't want change the reference of car,so we don't need use the ref keyword.
When you want pass type value parameters and want change the variable pass to method ,you use the ref keyword.and if you dont't want change the variables pass to method,you shoudn't use the ref keyword.
le van giang
|
|
|
|
|
Thanks
But it seems there are no harm to change the reference by ref.
And this add more functionality by using ref (except we cant
pass property and not initialized object reference to it ).
So, in what other situation that it is harmful to use ref ?
|
|
|
|
|
In any case when changing the reference will make you lose the reference to an object that you need.
Example:
You create a SqlParameter object and add it to a SqlCommand object. Now the command object also has a reference to the parameter.
You send your reference to a function that replaces the parameter with a new parameter.
You execute the command, which will place data in the parameter you added to it.
You try to retrive the data using your reference to the parameter, but as it no longer references the correct parameter, you won't get the data.
---
b { font-weight: normal; }
|
|
|
|
|