|
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; }
|
|
|
|
|
|
Hi Guyz,
Has anyone experimented with generating powerpoints from XML file? Need to do this as a part of developing a Learning Objects Repository.
Any help/comments would be greatly appreciated.
Thanks!
Sylvester, Asil Gerard
sylvester_26ATyahooDOTcom
|
|
|
|
|
In msdn library no sample.
It only have... "Birthdate < #1/31/82#"
But I need "Birthdate - Today"
Sorry, for bad English
Thank You.
|
|
|
|
|
using System;
namespace rfid_Beta
{
class MainClass
{
public static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}
when i tried to execute the above codes, nothing seems to happen. Any ideas why?
|
|
|
|
|
I guess you are creating a windows application, which has no console and therefor nothing happens.
www.troschuetz.de
|
|
|
|
|
Add followed expression at the end
Console.Read();
the output screen will delay until you press anykey.
using System;
namespace rfid_Beta
{
class MainClass
{
public static void Main(string[] args)
{
Console.WriteLine("Hello World!");
Console.Read();
}
}
}
le van giang
|
|
|
|
|
Try putting in Console.ReadLine(); just below Console.Writeline
|
|
|
|
|
Looks like it should work fine. How are you executing it? In a console window? Since it is a console app, you should be running it from the command line in a console window.
If you are running it from the IDE (Visual Studio), then look in the "Quick Console" tab down at the bottom. (That's what is is called in VS.Net Beta 2 -- I think it had a different name previously, but I forget exactly what; anyway, look for a likely output window tab at the bottom of the IDE).
By the way, it's "code" not "codes".
Matt Gerrans
|
|
|
|
|
Hi,
I have developed an application that runs on P.D.A as a final part I have upload the result to the Server from my P.D.A. database(SQlCe 2.0). I have written the web services programme on the server side,I a sending an array of objects to theservwer from P.D.A. Its working fine with the connection.But when i try to do the same using the G.P.R.S. its showing the following error
"MDCSTest.exe
WebException
Unable to read data from the transport connection
Application:Run+0xf
Form1:Main+oxa
Praveen.N
|
|
|
|
|
Hi Everybody,
How to open a new form when click on row of Datagrid in C#.
Thanks
|
|
|
|
|
Look into the dataGrid MouseUp event and DataGrid.HitTestInfo (to check if a row was clicked)
Then just call your form as normal Form1 f = new Form1(); f.show();
|
|
|
|
|
|
I would like to input data through a COM port and need to know how to tell C# to look for the COM port and to communicate witht he device atttached.
|
|
|
|