|
Hi..
I Want to upload pic in picturebox in runtime through database coz the pic location is save in my database
how can i do this plzz tell me
Thanls In advance
jawad kahtri
|
|
|
|
|
Is it only location which is saved in database or the image?
In case, it is only location you can use
Server.MapPath(##resultfrom DB##)
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
Yes only location.
Server.MapPath(##resultfrom DB##)
Server = databsename??
result from db = feild name???
|
|
|
|
|
mjawadkhatri wrote: Server = databsename??
Server.MapPath[^]
mjawadkhatri wrote: result from db = feild name???
The result which you get from the database.
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
Hi..
How to add two textbox text in one field of database??
thanks In advance
jawad kahtri
|
|
|
|
|
mjawadkhatri wrote: Hi..
How to add two textbox text in one field of database??
string str = textbox1.text + textbox2.text;
and add the str to database field.
Regards,
Karthik K...
|
|
|
|
|
Hi All,
I want to sort collections..
// Class
public class Item
{
public String Name{get;set;}
public int Cost{get;set;}
public Item(string name,int cost)
{
Name=name;
Cost=cost;
}
}
// Collection of Data
List<item> items=new List<item>();
items.Add(New Item("House",100));
items.Add(New Item("Car",80));
items.Add(New Item("Dog",10));
items.Add(New Item("Car",50));
items.Add(New Item("Cycle",25));
items.Add(New Item("Car",120));
Note:
Provide code to sort a collection of Item. The code should sort the Item collection only one time, following this rule: The Items should be ordered by their names (following the standard C# API for string ordering), but if two Items have the same name, then those Items should be ordered by their cost, with the lower cost item to appear before the higher cost item.
I appreciate somebody provide solution for the same.
Thanks & Regards
Rao
|
|
|
|
|
IEnumerable<Item> sortedItems = from i in items
orderby i.Name, i.Cost
select i;
Also look here[^], for more complex examples.
Uri
|
|
|
|
|
Thanks...
Thanks & Regards
Rao
|
|
|
|
|
Use this
public class Item : IComparable
{
public String Name{get;set;}
public int Cost{get;set;}
public Item(string name,int cost)
{
Name=name;
Cost=cost;
}
int Icomparable.CompareTo(object obj)
{
Item other = (Item) obj;
If this.Name < other.Name return -1;
If this.Name > other.Name return 1;
If this.Cost > other.Cost return 1;
If this.Cost < other.Cost return -1;
return 0;
}
}
Then you can just do items.Sort()
Probably worth having a look at IComparable and IComparer interfaces.
You could alsi look at using List<t> in generics namespace.
Regards
David R
---------------------------------------------------------------
"Every program eventually becomes rococo, and then rubble." - Alan Perlis
|
|
|
|
|
riced wrote: Item other = (Item) obj;
If this.Name < other.Name return -1;
If this.Name > other.Name return 1;
If this.Cost > other.Cost return 1;
If this.Cost < other.Cost return -1;
return 0;
Item other = (Item) obj;
int diff=string.Compare(this.Name, other.Name);
if (diff==0) diff=this.Cost-other.Cost;
return diff;
And using a generic IComparable, you wouldn't need the cast.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
That's much neater.
Looking at the OPs code I think they are a beginner, that's why I did it like I did and suggested looking at the interfaces.
Regards
David R
---------------------------------------------------------------
"Every program eventually becomes rococo, and then rubble." - Alan Perlis
|
|
|
|
|
Thanks..
Thanks & Regards
Rao
|
|
|
|
|
Hello All,
Is it possible to read from the working set of physical memory of a process I have identified (but do not have source control over) on my machine? Also trying to automate the windows forms associated with that process. I have been through the win32 api and have been able to get the handles I want, but cannot, for example, access controls or any other property other than handle and text(title).
Thanks in advance.
|
|
|
|
|
Hi,
yes you can interact with the memory belonging to another process; it takes P/Invoke to call Win32 functions such as ReadProcessMemory, WriteProcessMemory, VirtualAllocEx
I would suggest you search this site for articles with such keywords.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
how can i use the openCv with c# 2003 or 2005,,
any help please,,
thanks for anyone who will help..
best regards,
|
|
|
|
|
It took me 5 seconds to search in Google and get this[^] including a highly rated article[^] on this very site!
You waited half an hour to to be told, what you could have found in 5 seconds
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Latest studies confirm that a minimum IQ of 75 is required to form a search query in Google.
|
|
|
|
|
Hi,
I am working on a MS Word Automation project using VS2008 and Office 2003 in c# language. I have a One Page Word template which have bookmarks in table cells. These bookmarks are placeholders where specific information is put in from database using c#. I generate say 10 documents based on the template and save them as seperate file. What I would like is to have a 10 page single document. I can use selection.insertfile to create this document. When I do this, all the formatting goes bersek.
Basically what i do is:
Word.Application app = new Word.Application( );
Word._Document wordDocument = app.Documents.Add(
ref originalTemplate
, ref oMissing
, ref oMissing
, ref oMissing);
Word.Selection selection = app.Selection;
int documentCount = MyGeneratedFiles.Length;
int breakStop = 0;
foreach (string file in MyGeneratedFiles)
{
breakStop++;
selection.InsertFile(
file
, ref oMissing
, ref oMissing
, ref oMissing
, ref oMissing);
try
{
if (breakStop != documentCount)
selection.InsertBreak(ref pageBreak);
}
catch (Exception ex) { }
}
wordDocument = null;
app.Visible = true;
This works as far as combining all documents is concerned. But the formattign goes crazy and there are no clearly defined pageBreaks. Is there a better way to combine multiple one page documents into one multi-page single document? I have been stuck on this for a while, any help will be much appreciated.
Thank you
|
|
|
|
|
I have a wrapper class for a digital camera that is called from my form through camera.blah.
In the camera class there is a callback function for when the user pushes the shutter button. Within that camera class I can perform all kinds of things.
My problem is that I want to perform those tasks on the Windows form I am using, and I have no idea how to use the callback function to do something on my Windows form when the event is triggered.
I know this is difficult and vague, but without an idea of what to do here I don't know where to begin. I read that I cannot listen for events without using a delegate, which I am not familiar with.
|
|
|
|
|
eddieangel wrote: I know this is difficult and vague
It's not that bad really, sounds like someone tried to scare you..
You don't need to explicitly use delegates in order to use events, but of course under water there will be some messing with delegates (because that's the way an event remembers what it has to do when fired)
If you have an event you can just use += on it, and let intellisense do the rest (just press tab when it asks you)
|
|
|
|
|
Delegates work like this:
public class Camera
{
// There is a delegate here which will inform you when the shutter button is pushed
}
public class SomeListener
{
// Here you add a handler for the delegate
// You create an instance of the delegate found in the Button class and provide it with a method
// The delegate will carry out the method for you
// Your method must have the same signature as the delegate in the Camera class
// Within your method you will do something you want
}
Here is a button class which has a single event. The comments will guide you.
public class AButton
{
// This is the delegate
public delegate void ButtonClickedHandler(AButton sender, EventArgs e);
// This is an event which is basically an instance of the delegate
public event ButtonClickedHandler Click;
// Here is a method which will raise the click event
public void ClickMe()
{
// In C# first you check if anyone has created an instance of your delegate
// Whoever has created an instance is called the subscriber or listener
if (Click != null)
{
Click(this, EventArgs.Empty); // Call the listener's method that has this signature and let it do whatever it needs to
}
}
Here is a listener:
public class Listener
{
// First create an instance of the class
public Listener()
{
AButton b = new AButton();
// Now listen to the event
// Remember the delegate requires you to pass to it a method which has the same signature as the delegate
// This is like saying: "Hey a (which is an instance of AButton), when you are clicked please do what I want
// you to do in AButton_Click method.
b.Click += new Click(AButton_Click);
}
// Here is the method
private void AButton_Click(AButton sender, EventArgs e) // Same signature
{
MessageBox.Show("The button was clicked and this is all I want to do.");
}
}
}
}
CodingYoshi
Artificial Intelligence is no match for Human Stupidity.
|
|
|
|
|
I think I did a poor job of explaining, though I am sure that if I understood a little better I would be able to use the guidance here to solve my issue, consider the following code:
In the camera class:
private UInt32 PR_CameraCallBackFunc(UInt32 CameraHandle, UInt32 Context, IntPtr pEventData)
EVENT_GENERIC_CONTAINER pEventDataTemp = new EVENT_GENERIC_CONTAINER();
pEventDataTemp = (EVENT_GENERIC_CONTAINER)Marhsal.PtrToStructure(pEventData, pEventDataTemp.GetType());
switch (pEventDataTemp.Code)
{
case (UShort)prType.prptpEventCode.prPTP_PUSHED_RELEASE_SW:
break;
}
return (UInt32)prError.prOk;
All of the public propeties, methods, etc... of this camera class I can call from my windows form using camera.blah, but how do I trigger something on my Windows event form when this camera class event fires?
If I put code in the above case statement, it does fire when I push the take picture button on my camera, but how can I get my Windows form to listen for this event and perform events?
|
|
|
|
|
This actually isn't as complicated as it sounds!
Instead of a method being called directly, the call can be delegated - to a delegate.
One of the reasons for using a delegate for this (there are many) is methods cannot be passed as parameters to other methods, but delegates can (in C/C++ they pass a pointer [a pointer literaly points to a location in memory, or in otherwords is a value that is a memory address] to the callback function as the parameter).
So in the PInvoke function where the callback (the pointer to the callback function) is the parameter, in C# we pass a delgate instance. This delegate will then be called, which in turn calls the actual method you want to run.
I hope that makes sense!
All you need to do is create a delegate that returns the correct type, and has the correct signature:
private delegate UInt32 CameraCallBackDelegate(UInt32 cameraHandle, UInt32 context, IntPtr pEventData); Create your delegate instance and set up the method call, and you're done.
You have to be careful that your delegate doesn't go out of scope (i.e the instance gets garbage collected) while it can still be called by the PInvoke function.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Thank you, that was very informative. I have a grasp on the abstract concept of the delegate, what I am missing is the part where the form actually receives the event information from the camera class (Which is a DLL reference).
For any other event in the known universe, you would have an event handler on your form (Or class, or whatever you are building) that would look like:
CameraShutterButton_OnClick(object sender, eventargs e)
{
dostuff();
}
And that is great, as a matter of fact I have a button on my form that does exactly what I want the button on the camera to do. What I want to do is make the button on the camera (In the simplest terms) push the button on my form.
I can put the dostuff() into the actually CameraCallBackDelegate pEventData.type and have it perform some of the actions I need within the camera class, but how do I get my form to know what happened?
I am sure you guys have explained it very well and I am just having a tough time seeing the forest through the trees. I see the concept of delegates and understand the abstract, but I have yet to see a good example of it being used in these circumstances (That is a form listening for an event from an external device)
Maybe I should have titled this thread "C#, I don't get it" instead.
|
|
|
|