|
What is the best way to parse an xml file?
the XML reader class or the Regex class?
I need to connect to an access database that could be located anywhere on the local system but will have a DSN set up in the ODBC connectors. I know how to read the reg and find out if the DNS is setup
can i write directly to the DSN or do I have to read the DSN settings and set my DB connection in the program?
|
|
|
|
|
I've found that the DSN connection is not the best way to connect to the database and found how to connect to it, I will look at if I can build the OLE connector from reading the Registry
|
|
|
|
|
XmlDocument
Why use ODBC? Better to use the OleDb connecter.
I cobble up connection strings from values in XML.
|
|
|
|
|
All of the code that has been written before I started at this job has been written in VBscript. very impressive in everything that has been via VBscript. We have a bunch of people who run these scripts that allow you to put the database anywhere. the VBscripts all use the ODBC connector to write to the DB, so I'm looking for the solution that will allow the flexibility of still putting the database anywhere on the computer.
Is the ODBC connection settings stored in an xml file? I'm going to look at building the OleDb connectionString if I can find something static to build it from.
thanks for the recommendation of Xmldocument
|
|
|
|
|
Do someno knows a good truthful tutorial about using graphics on form
I've already read everything
1- Do not use a PictureBox to draw but a pannel
2- Do not use a pannel to draw but a picturebox
3- Use a pannel with doublebuffer
4- Do not use Doublebuffer but bufferedgraphics
and so and so ...
So for now I'm using PictureBox because I do not know how to draw on panel
I'm using graphics because I do not know how to use BufferedGraphics
And I don't know how to use doublebuffer
But I want to improve my knowledge but I don't know where is the truth ?
|
|
|
|
|
I doesn't matter too much where you draw, so long as you do it right. Basically, you either want to override the OnPaint method for a control (requires you to make a custom control, which is really easy), or simply use the OnPaint event. In either case you will get a Graphics object in the PaintEventArgs which is what you should use.
Now double buffering, try whatever it is you want without it (ie. Just draw your stuff using the aforementioned Graphics object). Then if you find that your form flickers, you may want to use double buffering. If you can it would be easier to use the DoubleBuffered property, if you can't then you can make up your own. Setting up your own double buffering is easy, simply create a bitmap with the same dimensions as your form/control and do all of your drawing to that, then you just draw the image to the screen in one go, like this:
Bitmap myBuffer = new Bitmap(200,200);
void OnPaint(object sender, PaintEventArgs e)
{
Graphics buffer = Graphics.FromImage(myBuffer);
buffer.Dispose();
e.Graphics.DrawImageUnscaled(myBuffer, 0, 0);
}
And if you want to go all out then check my articles here[^] (which one day I WILL get round to finishing dammit!)
My current favourite word is: Nipple!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|
|
Bitmap myBuffer = new Bitmap(200,200);
void OnPaint(object sender, PaintEventArgs e)
{
Graphics buffer = Graphics.FromImage(myBuffer);
buffer.Dispose();
e.Graphics.DrawImageUnscaled(myBuffer, 0, 0);
}
Hello SK Genius
I'm not sure about this example
1- You create a Grappfics 'buffer' FromImage(myBuffer);
2- Immediately after you dispose that 'buffer'
So what is the purpose of 'buffer' in that example ??
|
|
|
|
|
You do all your drawing onto the new buffer object, and then once you've finished you dispose of it.
My current favourite word is: Nipple!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|
|
IMO it doesn't really matter where you draw on.
If you need to redraw often use double buffering to avoid flickering.
The main thing you should ask yourself, when and how do I redraw?
eg. A while ago, when learning GDI+ on my own, I made the snake game. I used a panel and doublebuffering and it works perfectly. If I disable double buffering, the thing flickers a lot.
When did I redraw: When the snake moved
How did I redraw: I simply removed the last section of the snake and added one section in front instead of redrawing the entire thing.
|
|
|
|
|
Thank you V.
For my purpose I need to display a little portion of a big image and allow to move around the big image with zoom
So
1- I build the big image in memory
2- I take a clip of the big image on a smaller image (using DrawImage with a source rectangle on the big image and a destination rectangle on the small image
3- Then I assign the small image to the PB.Image
So everytime the user wants to move the image I process 2 and 3
My feeling now is that I can be more performant using a pannel instead a PB
And process 2 directly on the pannel surface without having to do 3
Am I right ?
|
|
|
|
|
If you want excellent performance for this, then you may want to use the old GDI which will be much faster, although it does involve P/Invoke and a fair bit more messing around it would definately solve any performance issues.
My current favourite word is: Nipple!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|
|
Thanks a lot SK Genius
I will consider this !
|
|
|
|
|
I'm trying to work with a user control that is added to the Winform at run time. The problem I'm dealing with is that the underlying properties and methods in the user control aren't inaccessible when using my approach. If I draw the user control directly on the Winform, the properties and methods are easily accessible.
The code I'm using to add the control is:
namespace WindowControlTest
{
public partial class WindowMain : Form
{
public WindowMain()
{
InitializeComponent();
int iPlayers = 4;
UserControl uctlPlayerPane = new UserControl();
switch (iPlayers)
{
case 2:
uctlPlayerPane = new uctl_2Player();
break;
case 3:
uctlPlayerPane = new uctl_3Player();
break;
case 4:
uctlPlayerPane = new uctl_2Team();
break;
case 6:
uctlPlayerPane = new uctl_2Player();
break;
}
uctlPlayerPane.Location = new Point(25, 25);
this.Controls.Add(uctlPlayerPane);
}
}
}
When I go through the debugger, the property does appear under uctlPlayerPane under the [WindowControlTest.uctl_2Team] entry, but I can't seem to figure out how to get at it. Am I using the wrong approach for this, or am I missing something else.
Thanks all.
|
|
|
|
|
You'll need to cast uctlPlayerPane to the correct type to access that type's properties and methods. To know which type it is, you can either do
if (uctlPlayerPane is uctl_2Player)
{
...
}
else if (...
or create an enum of the available types, use a private variable to indicate which type is selected and use an if or switch on that.
Both of the above will get cumbersome though so it may not be the best solution, but it will work!.
You could have an interface that specifies all the methods and properties that all the controls will have, and throw NotImplementedExceptions in the controls where the property or method would not normally be available and catch them as neccesary. I don't like deliberately throwing exceptions, but again, if suitable for your purposes, it will work.
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)
|
|
|
|
|
Hello,
I currently have a reportviewer on my form and I wish to export the data to an Excel and/or PDF file. I know this can easily be accomplished using the built in toolbar of the reportviewer but I want to be able to use my own buttons. I don't see the need to render my own report as I want to do exactly as the toolbar drop down for exporting to Excel and PDF does already. I just want to instigate this process using my own button. Does anyone know if this is possible?
Thanks for your time!
Christian
|
|
|
|
|
I know that the Crystal Reports objects directly support outputting through code and samples are available online.
Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
Most of this sig is for Google, not ego.
|
|
|
|
|
Thanks for the response! My reports are already designed so I think I'm stuck with the built in reports and reportviewer.
I want to do exactly what the built in toolbar does but from my own button.
Thanks!
|
|
|
|
|
I want two fields as ID fields(Value Member) along with a Display Member for DataGridViewComboboxColumn. How can I implement it?
|
|
|
|
|
what do you have to show? why can´t you do that? do you are able to connect to database?
nelsonpaixao@yahoo.com.br
trying to help & get help
|
|
|
|
|
I have created the following:
public interface ICalculatable
{
DateTime FirstPaymentDate { get; }
decimal MonthlyCompoundingRate { get; }
}
public interface IBaseObject : ICalculatable
{
string Identifier { get; }
DateTime FirstPaymentDate { get; set; }
decimal InterestRate { get; set; }
}
public class BaseObject : IBaseObject
{
...
}
I get a compiler error that need new to hide inherited member. I am trying to figure out if that is the correct thing or I need to use virtual/override/etc.. instead.
I will be accessing the BaseObject as ICalculatable in other code and the FirstPaymentDate properties should be the same value/source.
Thanks in advance.
WarePhreak
Programmers are tools to convert caffiene to code.
|
|
|
|
|
in ICalculatable FirstPaymentDate just has a get
in IBaseObject (which implements ICalculatable) it has a get and a set, so the compiler is saying its not being implemented with the same signature, therefore you need to add the new keyword to hide the base FirstPaymentDate in ICalculatable
like so
public interface ICalculatable
{
DateTime FirstPaymentDate { get; }
decimal MonthlyCompoundingRate { get; }
}
public interface IBaseObject : ICalculatable
{
string Identifier { get; }
new DateTime FirstPaymentDate { get; set; }
decimal InterestRate { get; set; }
}
EDIT
I have just reread your question and the above does not help does it
Best way is to try it out in a demo project
|
|
|
|
|
Ware@Work wrote: the FirstPaymentDate properties should be the same value/source.
IBaseObject has no value/source. Only the implementer does so this is not relevant to your scenario. It might be possible for the implementer to explicitly implement the two interfaces giving the implemented class different value/source. I have never tried it because, well it seems like a bad idea.
Also it is possible that there is different design than the two interfaces you are using that might better suit your needs. Perhaps reading Allen Holub discuss why Getters and Setters are Evil[^] will help you.
led mike
|
|
|
|
|
led mike wrote: Perhaps reading Allen Holub discuss why Getters and Setters are Evil[^] will help you.
Read the article but it is focused more on the class design. If I understand it correctly, I am doing fine because I am creating an interface to define the contract that will be passed around.
I will have a calculator object that accepts the ICalculatable as a parameter to a RunCalc method. This will ensure I have access to the values I need to do the calculation. BaseObject is a business object. The calculator object will be business intelligence. I don't care about the actual implementation under the covers.
How do I define IBaseObject to imply that the FirstPaymentDate property is the same in both the IBaseObject definition and the ICalculatable definition?
WarePhreak
Programmers are tools to convert caffiene to code.
|
|
|
|
|
Ware@Work wrote: How do I define IBaseObject to imply that the FirstPaymentDate property is the same in both the IBaseObject definition and the ICalculatable definition?
You leave it off of IBaseObject altogether, as IBaseObject inhertits from ICalculatable (and assuming you implicitly implement the interface) any instance of a class which implements IBaseObject will have access to the required method.
Scratch all that, I see it is get/set in IBaseObject and get only in ICalculatable. In which case I would do it as follows:
public class BaseObject : IBaseObject
{
#region IBaseObject Members
public string Identifier
{
get { throw new NotImplementedException(); }
}
public DateTime FirstPaymentDate
{
get
{
throw new NotImplementedException();
}
set
{
throw new NotImplementedException();
}
}
public decimal InterestRate
{
get
{
throw new NotImplementedException();
}
set
{
throw new NotImplementedException();
}
}
#endregion
#region ICalculatable Members
public decimal MonthlyCompoundingRate
{
get { throw new NotImplementedException(); }
}
#endregion
}
Anything that has a reference to BaseObject (or IBaseObject) can get/set FirstPaymentdate. However anything with a reference to ICalculatable will only be able to get.
|
|
|
|
|
You got into the implementation. I want to define the contract so that any object that satifies IBaseObject will by nature satisfy ICalulatable and be usable as such.
Is using new on FirstPaymentDate the correct way to do so? I tried using virtual/override and it wouldn't let me do that. So I am beginnining to believe it must be.
Thanks all for the help.
WarePhreak
Programmers are tools to convert caffiene to code.
|
|
|
|