|
Hello,
I want to develop my own control for table which contains links which
referes to other Forms of a Smart Device Application for PocketPc. Does there any code samples exist which show such a development?
thx
regards
patrick
|
|
|
|
|
How do you create a user control by name in code.
Say I read in control names from a file. How do I then create them in code. In VB6 there was a CreateObject method but I can't find anything similar in C#
|
|
|
|
|
|
Thanks Stefan,
I used the Activator class to create the user control by assembly name and user control namespace and name e.g.
public static object CreateOject(string AssemblyPathName, string NamespaceClass)
{
Assembly assembly;
//Can be used when instance in another assembly
try
{
assembly;= Assembly.LoadFile(AssemblyPathName);
}
catch (System.IO.FileNotFoundException e)
{
throw an exception
}
System.Type TypeToCreate = assembly.GetType(NamespaceClass);
if (TypeToCreate == null)
{
throw an exception;
}
return Activator.CreateInstance(TypeToCreate);
}
Note you don't have to create the assembly object if the type is part of the same assembly or GAC, you can just get the Type by:
Type TypeToCreate = Type.GetType(NamespaceClass);
|
|
|
|
|
Hello,
I found the following code sample to create Image Buttons for PocketPc. The problem is i do not really know how to use it. means how to create an Image Button with this code sample...?
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Drawing.Imaging;
namespace Sample
{
public class ImageButton : Control
{
private Image image;
private bool bPushed;
private Bitmap m_bmpOffscreen;
public Image Image
{
get { return image; }
set { image = value; }
}
public ImageButton()
{
bPushed = false;
this.Size = new Size(21, 21);
}
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e )
{
Graphics gxOff;
Rectangle imgRect;
Brush backBrush;
if (m_bmpOffscreen == null)
m_bmpOffscreen = new Bitmap(ClientSize.Width, ClientSize.Height);
gxOff = Graphics.FromImage(m_bmpOffscreen);
gxOff.Clear(this.BackColor);
if (!bPushed)
backBrush = new SolidBrush(Parent.BackColor);
else
backBrush = new SolidBrush(Color.LightGray);
gxOff.FillRectangle(backBrush, this.ClientRectangle);
if (image != null)
{
int imageLeft = (this.Width - image.Width) / 2;
int imageTop = (this.Height - image.Height) / 2;
if (!bPushed)
imgRect = new Rectangle(imageLeft, imageTop, image.Width, image.Height);
else
imgRect = new Rectangle(imageLeft + 1 , imageTop +1, image.Width,
image.Height);
ImageAttributes imageAttr = new ImageAttributes();
imageAttr.SetColorKey(BackgroundImageColor(image),
BackgroundImageColor(image));
gxOff.DrawImage(image, imgRect, 0, 0, image.Width, image.Height,
GraphicsUnit.Pixel, imageAttr);
}
if (bPushed)
{
Rectangle rc = this.ClientRectangle;
rc.Width--;
rc.Height--;
gxOff.DrawRectangle(new Pen(Color.Black), rc);
}
e.Graphics.DrawImage(m_bmpOffscreen, 0, 0);
base.OnPaint(e);
}
protected override void
OnPaintBackground(System.Windows.Forms.PaintEventArgs e )
{
}
protected override void OnMouseDown ( System.Windows.Forms.MouseEventArgs e )
{
bPushed = true;
this.Invalidate();
}
protected override void OnMouseUp ( System.Windows.Forms.MouseEventArgs e )
{
bPushed = false;
this.Invalidate();
}
private Color BackgroundImageColor(Image image)
{
Bitmap bmp = new Bitmap(image);
return bmp.GetPixel(0, 0);
}
}
}
|
|
|
|
|
I would like to store an image in an SQL Server database and load it into a picture box.
Has anyone had experience with doing this before?
An example would be appreciated.
Thanks
Stephen
|
|
|
|
|
I would usually store the address of picture in the database instead of image itself, you can do this too unless you don't want your pictures stored in folders.
|
|
|
|
|
HI~
I am writing a program to send email using simple mapi.
When I use the MAPISend to send the email, the new mail is not sent actually. The mail is just put on the outbox of the outlook express. Also the MAPIFindNext method also just get the mail from the inbox of the outlook express but not get the mail from the internet email server. Only when I download the email by using outlook express, my program can get the new mail.
Can I automate the sent process and the receive process so that the email is actually sent and the new mail can be retrieved from the internet server by press the button of my program by using Simple mapi?
|
|
|
|
|
simply i want to know how to add two integer numbers in C#. i'd appreciate your help guys.
|
|
|
|
|
int firstInt = 3;
int secondInt = 2;
int result ;
result = firstInt + secondInt;
The + operator will add together most any of your basic types: int, long, short, string, etc. Hope that helps.
Quantum materiae materietur marmota monax si marmota monax materiam possit materiari?
|
|
|
|
|
but here you arleady assigned values to the two integers, what I need is to make a program that takes two input numbers from user and then adds them. thx a lot for ur reply anyway.
|
|
|
|
|
Class abc
{
int a=System.Console.ReadLine();
int b=System.Console.ReadLine();
int c=a+b;
}
/\ |_ E X E GG
|
|
|
|
|
Well does it need to be a console application or a Windows Forms application? Or even an ASP.NET application? The basic principle remains the same...it's just a matter of gathering that input from the user.
Quantum materiae materietur marmota monax si marmota monax materiam possit materiari?
|
|
|
|
|
How about voice recognition? That'd be cool
--
Help me! I'm turning into a grapefruit!
Phoenix Paint - back from DPaint's ashes!
|
|
|
|
|
Even better, thought recognition. The ultimate lazy mans computer.
|
|
|
|
|
It looks like you want to add two numbers
Would you like help?
- Get help thinking of a number
- Just carry on adding without help
Oh god...
--
Help me! I'm turning into a grapefruit!
Phoenix Paint - back from DPaint's ashes!
|
|
|
|
|
And since it's a thought computer, the thing is going to project an image of Clippy directly into my optical nerves. Great.
Quantum materiae materietur marmota monax si marmota monax materiam possit materiari?
|
|
|
|
|
Hi,
I have to write an application which extensively uses an SQL Database. For a simple example say I have the following tables with the appropriate fields.
1. Company (ID, Name, AddresseInfoID)
2. AddresseInfo (ID, Street, City, Zip)
(Those two obviously have a relationship)
Now I'd go and create an object called Company and one for the AddresseInfo. AddresseInfo would be a public member of Company.
Usually you'll have more than one company to manage so I create a strongly typed collection called CompanyCollection.
Now on to the questions:
1. Should each individual object be responsible of loading and saving it's data from and to the database or should the CompanyCollection take care of it (which IMHO seems a lot less coding to me on first sight)?
2. Assumed the Collection takes care of the data-fetching, how should then the data changes whithin the individual objects be handled? What comes in mind is either a IsDirty property of each of the BusinessObjects (Company and AddresseInfo) (which can be checked by the collection) or an event (say DataChanged) to which the collection would hook up.
The problem I see with this approach is the following. Say my MDI GUI displays a list of all Companies in a TreeView on the lefthandside. On DoubleClick the selected BusinessObject gets displayed in a new "Document Window" which hosts a PropertyGrid control. Now my user opens 3 Companies and changes the data of all of them. How would I then handle the situation when he only wants to save to of those documents?
Here is some additional information which I feel might be usefull:
a. The amount of BusinessObject loaded from the Database is never really huge. Say a maximum of 2000 objects.
b. BusinessObjects might contain collections of other BusinessObjects, e.g. the Company object will contain a EmployeeCollection.
c. The amount of different BusinessObjects will probably not exceed 20.
d. Performance issues are not a knock out criteria.
e. The solution that I'm after is simple to code and maintain. I don't actually want to create a huge Framework with hundrets of classes which provide for unlimited scalability and the forth. We are talking about an application which is used by 10 people and new versions can be installed at any time if required.
I hope someone can give me some advice on how to design this properly.
Thanks in advance,
Matthias
If eell I ,nust draw to your atenttion to het fakt that I can splel perfrectly well - i;ts my typeying that sukcs.
(Lounge/David Wulff)
|
|
|
|
|
hi,
Good question. See i can help some part of your problem. Say
Mathias Wrote:
The problem I see with this approach is the following. Say my MDI GUI displays a list of all Companies in a TreeView on the lefthandside. On DoubleClick the selected BusinessObject gets displayed in a new "Document Window" which hosts a PropertyGrid control. Now my user opens 3 Companies and changes the data of all of them. How would I then handle the situation when he only wants to save to of those documents?
So some cases user may changes few document against a list. Here you can use indexcer to get proper instance of object from your collection which hold real updation. I think this is the better way to know and choose a perticular record which have updation. I already faced the same situation that you mentioned in your queary. Here i applied indexcer to tackle my issue. And it is pretty fast than checking all objects in collection.
Sreejith Nair
|
|
|
|
|
You Wrote:
The problem I see with this approach is the following. Say my MDI GUI displays a list of all Companies in a TreeView on the lefthandside. On DoubleClick the selected BusinessObject gets displayed in a new "Document Window" which hosts a PropertyGrid control. Now my user opens 3 Companies and changes the data of all of them. How would I then handle the situation when he only wants to save to of those documents?
In My Opinion:
Save one on one basis that is "Save" can be done on open screens only. When your application user double clicks the company tree view a "document window" with company details with a save button will be presented to user. If the user want to persist the chages, he'll hit save and your code will invoke save inteface on the business object. This will save you scanning all objects in collection and will also save you from maintining that which objects have been changed.
Some other suggestions:
Creating objects for all companies may not be an optimal idea. Only fetch company names and Identification info (IDs) from database and render it to tree view. Obviously these objects will be lightweight as no company info is fetched. Now, if your app user selects a company, create a Object of Class Company with all the company details and render it to user.
hope it helps,
Hatim Ali.
|
|
|
|
|
|
Hello, I´sorry, my english not´s very good.
Send my one example:
1- Read one word document in C#
2- add one value in n positions.
Please, your e-mail write in spanish
|
|
|
|
|
|
My problems are:
1- Insert an read one value in one positiion, in the document, in the specific paragraph, for example, insert my name in te line 1 of paragraph 2, in the position 13
This is example number 3 for book C# Proffesionals Projects
Please, my english not is very good. Sorry.
|
|
|
|
|
Hi,
I've searched hi and low to find out how you can draw outside of the Form, but haven't found anything! I posted the same question on the VB.NET forum, but didn't get a single response.
Please can anyone help?
I'm trying to draw rectangles outside of my Form, of course it gets Clipped by the Form itself. I've tried to modify the Clip for the Form, but I can't seem to change it whatsoever. Is it possible to create a Graphics object for Windows itself? So that you can draw anywhere on the screen??
Any help or advice would be much appreciated!!
Many thanks!
Richard
|
|
|
|