|
How to create expression column named Age from the existing column BirhtDate?
Sorry for bad English.
Thank You.
|
|
|
|
|
int Age = DateTime.Now.Year - birthDate.Year;
What do you mean by 'expression column' ? You want to show this in a datagrid ? Then you need a column that binds to a function that calls the above code.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi, Sir.
I mean...
DataColumn c = new DataColumn();
c.Expression = "BirhtDate - DateTime.Now";
Is it possible to create a column like I mean above?
Thank You.
|
|
|
|
|
Well, that expression is wrong, but the answer is I don't know if it can be done directly, I doubt it very much. The Expression needs to be SQL. Actually, SQL Server has a Now property, or something along those lines, I wonder if that would work ?
Try DATEDIFF('yyyy', BirthDate, GetDate()). If that doesn't work, then I'd say nothing will. You definately cannot use C#, you need to use SQL if you do it this way.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
hi, there is error ina parameter int that SQL function.. the 1st parameter should b DATEDIFF(year,birthday,Getdate())..or DATEDIFF(yyyy,birthday,Getdate()) but the 1st is more accurate i think. that would work as an expression for a column in ur table as it returns only one value
IF u need help...Help the others
|
|
|
|
|
when I bind a dataset to a datagrid (I did it so many times and they always run well but sometimes I meet some mistakes with the same code ...I think that because my database...):
I bind datagrid with a dataset ...and then I use bindingManagerBase.position to move next and pre ,that's normal but when I press the button AddNew(using BindingManagerBase.AddNew()) .It make a new row in datagrid but the cursor don't move to the new row ( It should move when I use the same code in another window form ,it run so well...) and then I can't move Last(after I add a new row in datagrid)...
I don't know why the same code but it takes various result....Could you please to help me?...I must complete this project soon...Thanks first....
The man with nothing to lose
|
|
|
|
|
How to convert bytes in bitmap code
|
|
|
|
|
My image processing code shows you how, basically you need to create the bitmap first, then stuff your bytes into it.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
How to convert bitmap in bytes code?
|
|
|
|
|
Damn, didn't I just answer this ?
If you want the answer in C# to both this and the question above, read my image processing articles on this site. I've already answered this in C++ today, I assume it was you ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I have an app which is going to use an image library. I'd like to put the library into a DLL which exposes a hashtable, where the names of the images are the keys, and the images are the values. Then I can use the Keys property to get the names for a drop list, and pass the selected names back to get an image.
The thing is, I want to be able to change this dll and replace it without changing the exe. From what I've seen, I think that the compiler binds to the DLL so that if I change it, I need to rebuild. Is there a way of late binding to a dll so that I can do what I want ? Or will it just work and I'm worried about nothing ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Christian Graus wrote:
Or will it just work and I'm worried about nothing
It may work,as the clr compiles it at run time ,so it will use that resources when the exe is executed ,AS I THINK
|
|
|
|
|
Yeah, it seems possible, the stuff I've had trouble with is COM based, which is a whole different thing.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
You didn't say.
|
|
|
|
|
No, I had trouble with COM *before*, which is what's made me wary. A COM dll that had a new version, but the same GUIDs ( I did NOT write it ), would not run even though I was calling old methods that were still in there.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Christian Graus wrote:
I think that the compiler binds to the DLL so that if I change it, I need to rebuild.
Hmmm. If you're talking about .NET assemblies, you can load/unload assemblies at runtime by setting up a separate AppDomain. I've never done it though, so I don't know how to go about the nitty gritty stuff.
Or are you talking about a classic DLL, like C or C++ generated, where you use DllImport in C#? (or, shiver, managed C++).
Marc
My website
Latest Articles:
Object Comparer
String Helpers
|
|
|
|
|
Marc Clifton wrote:
Hmmm. If you're talking about .NET assemblies, you can load/unload assemblies at runtime by setting up a separate AppDomain. I've never done it though, so I don't know how to go about the nitty gritty stuff.
Great - I'll look into it.
No, it's a C# dll, at least in my head it is. It seems the easiest way to go to me.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Unless you don't change the expected interface of the needed classes in the DLL you can just exchange it. I've done that quite some times with a customer who needed an urgent update and I just sent him one of the projects dlls.
|
|
|
|
|
I need to draw a rect of another Image source inside a Picturebox.Image.
Then i need to draw a second rect from another Image yet inside Picturebox.Image but when i try to do that the picturebox is empty and it draw the new one deleting the old one.
I need to do as this image:
http://www.bbcometa.com/images/img.jpg
Thanks to who can help me.
|
|
|
|
|
You cannot draw onto a picturebox, you need to create a third image from the first one, then you need to use Graphics.FromBitmap to draw part of the second image onto the third one.
Then place the third image into the picturebox.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
When you draw the second rectangle,the control refreshed itself and clear that one that was created by a graphics object,so you must save it before you draw the second one,or draw all in the in paint method.
|
|
|
|
|
Yeah, overall I think using a picturebox is a bad idea, unless someone just wants to show a picture and get some scaling code for free.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
What i have to use instead of picturebox if i want to show it in a form?
|
|
|
|
|
Just use any inherited Control and override OnPaint of it.
|
|
|
|
|
Where Photoshop or other graphic program draw the image got by all the levels?
It seems a PictureBox.
Anyway i've not idea what i have to do in the OnPaint function?
Could you be more detailed, if you can with a bit of code?
Thanks
|
|
|
|