|
Yes.
<italic>Work hard and a bit of luck is the key to success. You don`t need to be genius, to be rich.
|
|
|
|
|
Yes. Use ADO.NET's OleDb* classes with a connection string for your Access database, which you can check here[^].
If you don't know how to use ADO.NET, there are several articles here in CodeProject about it. Just search this site or try here[^].
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
Thanks Luis for the info, I wanted to use Access database. I guess if I had to I could us SQL.
Thanks again
David J Harmon
|
|
|
|
|
Cappuccino_David wrote:
I guess if I had to I could us SQL.
You can have the same code use either SQL Server/MSDE or Access if you use the OleDb* classes. You only need to change the connection string.
If you use the Sql* classes you'll get better performance, but will be limited to SQL Server.
Good luck!
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
I am having an interesting situation. I have some a run-time control that is parented to a child run-time control on the main form. When I minimize the form, and then maximize it again, the child control is not entirely displayed. The display for all of the controls, parents and children is fine at the beginning when the application is initially run. However, when the form is minimized and then maximized again, all that is displayed is the part of the child control that is visible inside the parent control. What could be the possible reason? What is going on that is causing only part of the children to be displayed? Is it related to repainting the control.
Does the clipping rectangle have anything to do with why all of the child controls are not displayed when the form is re-maximized? Is there any form of onMaximize(), that could control the event for maximizing the form?
Also, regarding the .NET approach to double-buffering using this.SetStyles(ControlStyle.DoubleBuffer, true), and the other two required commands, would including them more than once increase the buffering capacity? Is there perhaps some way of getting a quadruple buffer to help reduce the flicker of run-time controls?
As an example, for flicker, open up Visual Studio and open up a project. Then press Ctrl-Alt-Delete and open up the Task Manager. Drag the Task Manager around the screen. It leaves a trail of window ghosts. How would I prevent these ghost imprints from being left on one control by either other forms or by other controls, unless there is a capacity to increase the buffering?
|
|
|
|
|
Read the documentation for the ControlStyles.DoubleBuffer enumeration member. You must also specify ControlStyles.AllPaintingInWmPaint and ControlStyles.UserPaint for it to be effective, and that will only be effective if you are painting controls yourself.
Most of the Windows Forms controls encapsulates the native Windows Common Controls - the very controls you see most other applications using including Windows itself - so they are already drawn about as efficiently as possible. Double-buffering your canvas often won't change their drawing behavior at all. If you're noticing flickering, chances are that your computer isn't exactly up to par. No offense.
It could also be that you're responding to an event like the Paint event in your application and performing rather long operations. The Paint event handler (or overriding OnPaint for extended controls, which is a faster and better approach) happens in the main thread depending on the circumstances, so any operations you do block the main thread.
Regarding your resize problem: how are you positioning the controls? Just laying controls out on the container and even setting a mix of Dock and Anchor properties shouldn't cause this, and I've never seen it in all my experience.
And what do you mean when you say "parented to each other". Are these child controls with child/container controls? Or are you saying that each control is sited to another, meaning that they are laid out adjacent to each other. If that's the case, parenting is a different thing. Child controls are parented to container controls. Siting is laying out adjacent or "sibling" controls in a particular manner where their position is relative to one another. If that's the case, how are you implementing it?
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Heath:
Regarding the possibility that my computer might not be up to par, that is a distinct possibility. The computer that I am using to develop this .NET application is a 200 MHz Gateway Pentium Pro with only 98 MB of RAM with an 80 Gig hard drive that is half full. Could this be responsible for the flickering effect, and the leaving of ghost images when another form is moved over the main form? I know, I should probably upgrade the computer, but there are financial constraints that prevent this from occurring just now.
Which brings up another question... I have just recently added all of the Windows 2000 Professional components, including IIS and SMTP, and all the rest, and now I get a warning message that says the "maximum registry size is too small", and that I need to change it for windows to run properly. Where would I go to increase the O/S maximum registry size?
I already am implementing the three commands. Now, the question is WHERE should they be implemented to get the MOST EFFECT, and why? Should it be in the form onLoad() event, or should it be in the InitializeComponent() routine, or could it be properly placed in an individual program routine? Would including these three commands several more times improve the buffering capacity further, and is it possible for the buffering capacity to be increased to four times or more?
Regarding the positioning of parented controls, say you have one control that is on a form added as a run-time control, and another control that is a child to the parent control that is slightly off-center also added as a run time control (neither are as a design time control). For example, say the child run-time control has a location that is fifty pixels off to the right or fifty pixels off to the left. When they are parented together like this they can move together, but when they are off center from each other, the "entire" child does not show up when the form is minimized and then maximized again. Said another way, the only part of the child that is displayed is the part that overlaps with the parent control container, the rest of the child is not displayed. What could cause this? Is there a "private void override repaint()" method to correct this? Also, is there some way that the form could be repainted onMaximize() or is there a better way?
Sure, I realize that I could EXPAND the parent size (container size) to encompass ALL of the child, but then that would have the effect of stretching the parent backgroundimage. Plus it would be a quite messy end result. How could I display ALL of the child without the need to expand the parent container size?
The code is as follows:
<br />
_ctrl.Paint += new PaintEventHandler(_ctrl_Paint);<br />
<br />
<br />
private static void _ctrl_Paint(object sender, PaintEventArgs p)<br />
{<br />
Control ctrl = (Control)sender;<br />
Graphics grfx = p.Graphics;<br />
Rectangle clientRectangle = new Rectangle(0, 0, ctrl.Width, ctrl.Height);<br />
p.Graphics.DrawImage(ctrl.BackgroundImage, clientRectangle);<br />
}<br />
<br />
I should add here that the image file that is attempted to be presented as a background image is really larger (related to width and height) than the size provided by the clientRectangle. Where would I use the clipping rectangle in the above code? When the control is clicked, it causes the original size of the resulting image to be displayed for a very short interval. What could be causing this, and would repainting the control fix this problem as well?
|
|
|
|
|
new_phoenix wrote:
Which brings up another question... I have just recently added all of the Windows 2000 Professional components, including IIS and SMTP, and all the rest, and now I get a warning message that says the "maximum registry size is too small", and that I need to change it for windows to run properly. Where would I go to increase the O/S maximum registry size?
For starters, why do you need all that installed? You're already pushing memory to the max. Do you require a web server on your machine? Whidbey will allow you to develop web sites locally without requiring IIS (including an ASP.NET host it starts and stops to test). Do you need the SMTP service to 1) send mail yourself directly to the destination host, if your ISP even allows that, or 2) more often than not the SMTP service is used to forward mail to another SMTP server that must be configured to allow forwarding from your machine. Don't run what you don't need, especially with so little memory and a slow CPU.
To change the registry size, right-click on "My Computer", select Properties, and go to, IIRC, the "Advanced" tab. The setting should be somewhere in there.
new_phoenix wrote:
Regarding the positioning of parented controls...
Whenever a control is invalidated - by something covering it up or the control was hidden from a minimize or something else - the system will send WM_PAINT to tell the control to repaint, along with the region of the control that must be repainted. If part of your control is obstructed, it is not drawn. Period. There's no way to override this. While you can draw to off-screen buffers, unless you actually swap buffers yourself Windows will not help you. There is layered windows (which is basically what I described above), but that only works on Win2K and above and requires you to P/Invoke several native APIs and implement drawing yourself. Again, this will not affect most controls that encapsulate the Windows Common Controls (which is most of them).
One problem I see in your code is that you're drawing the entire background image. As I said before, this is wasteful (especially on your 200 MHz machine). That PaintEventArgs passed to you includes a property named ClipRectangle that defines the rectangle that only needs to be redrawn. Doing some simple math to get the interestion of the clipping rectangle for the entire bounds of the control is much more efficient than drawing the whole image. The Rectangle struct even has a help method to make this easy: Rectangle.Intersect .
I would recommend making this simple change and try it on a faster computer to make sure that it's not something else you're doing. You barely meet the recommended system requirements for Win2K, so that could be causing a problem.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Heath:
Thanks, I found the place to change the maximum registry file settings. I boosted it from 25 MB to 50MB, and while I was at it, I boosted the virtual memory size from 20 MB to its absolute maximum capacity of 4095 MB virtual memory paging file size.
Do you have any other recommendations for tweaking out the computer so that it is faster and more efficient like more modern computers, and that would allow me for the time being to "make due" until I could get a new computer if the IT industry ever recovers in the United States?
New_Phoenix
|
|
|
|
|
|
Hello all,
I'm new to C# and am looking for some guidance with serialization of dialog data. I have created a simple app that produces a data product based on the settings entered by the user on a single form. For now I have created a simple serializable class containing member vars that correspond to the various controls on the form. Just prior to calling Serialize( ) I manually set the member vars in the class to the corresponding values of the controls on the form. Like-wise, I manually set the values of the controls to the member vars of the class after calling Deserialize( ). There has to be a better way…
I guess another fundamental issue for me is that I’m not used to dealing directly with the control – I’m more used to having a separate member variable that automatically gets stuffed with the value of the control (like MFCs DoDataExchange( )). Is there a slick way of doing this without writing a bunch of code (for example without adding code to the Validated event of every control on the dialog)?
Thanks for your help,
Newbie_T
|
|
|
|
|
A better way would be to data-bind your controls to a DataTable , which is part of a DataSet which serializes nicely into an XML document (also see the XmlDataDocument for faster access to the XML document itself, but which can return you a DataSet if you need it later, like for data-binding purposes).
Start by reading Data Binding and Windows Forms[^] in the Visual Studio product documentation.
You can add a new DataSet schema to your project just like you'd add a new class. It's an XML Schema that is used to generate a strongly typed DataSet , where all of the tables, columns, relationships, and keys are defined when you instantiate it (otherwise you have to do this programmatically, and binding because a manual operation because the designer can't infer what can be bound). Use the "Data" section of the toolbox to add a DataSet, and select your DataSet -derived class when prompted.
Now go to each control and find the "Bindings" category. You can use the "Advanced" ... button to bind. While it's generally a better practice to bind to a DataSet and set the DataMember property of a control to the name of the table (like for a DataGrid , to better facilitate data navigation and multiple table views), not every control implements a DataMember property. When data-binding controls all controls should use the same binding context (which means the exact same combination of the data object and the data member, and they need not be a DataSet or DataTable , but any IList or IListSource implementation).
When your form loads (so override OnLoad and don't forget to call base.OnLoad after deserializing your data) you use your DataSet field and call DataSet.ReadXml , for example. When closing (so override OnClosing , and again don't forget to call base.OnClosing when appropriate - almost always call the base implementation when overriding) use DataSet.WriteXml .
To make sure you write to the right file, use an absolute path since the current working directory for your application could be different depending on how the application was launched. For the best user experience, write to a directory they would have write access to, and that wouldn't set preferences for all users, unless that's what you wanted.
For example:
string path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
path = Path.Combine(path, "My App");
Directory.CreateDirectory(path);
path = Path.Combine(path, "settings.xml"); If you wanted to save the settings relative to the application, be sure to use the application's startup path (the directory that contains the EXE):
string path = Application.StartupPath;
path = Path.Combine(path, "settings.xml"); This really is similar to what you would do for MFC, only that your binding to an object rather than having to implement the data transfer to some object yourself. And instead of archiving that object (using a CArchive or some custom solution), you're serializing it. The DataSet provides methods to serialize and deserialize more easily than for more serializable objects, too.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Now I like to use C# program to modify tnsnames.ora content using
the related methods provided by system lib.
For example, after a client accepts the related values , such as
"zgafc", "109.52.8.8", "1521" and "db.source", then the client can modify (or insert) the file "tnsnames.ora", as following :
ZGAFC =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 109.52.8.8)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = db.source)
)
)
then the client can access the db by "zgafc" in client program.
that's to say, if the client just install the oracle client, and do not
config the source in client, however, it can access the appointed database
after the client accept the values related to connection.
If we can find the methods, we can create the database source in client by program, rather than config the datasource in client by manual.
|
|
|
|
|
Hello,
When the user of my app selects some rows from an open excel file and
drag-n-drops them onto my form, I need to be able to parse those rows and
fill arrays that would match the original selected Excel rows.
Is there any way the I can populate an array with data from CSV's that are just droppped
onto the form?
I tried parsing each line myself, using some regular expressions I found
online, but they would fail if a cell in the Excel row contained quotes or
commas.
What I have right now is a streamreader which reads the dropped info. As long as there are more lines, I read the line, split it using comma as the delimeter, and fill an array. This works great if there are no commas or quotes within the excel cells. If there are, I cant just split the string on commas because I cant tell the difference between "real" commas and the delimeters.
I see that when you drag-n-drop Excel rows onto say Wordpad, it gets it right (regardless of what is in the Excel row). I would like to be able to do the same (just fill arrays instead of displaying the data).
Any help is GREATLY appreciated!
Thanks
-Flack
|
|
|
|
|
You need to parse the CSV data correctly. That means anytime you encounter a quote you don't slip on commas (or tabs, whatever the delimiter may be) until you reach another quote. It's a pretty basic state machine. While you could use regular expressions, it would be much easier to just read-in the entire line and parse the string character by character keeping track of what characters you've read (using the rules I mentioned above) and splitting at the right time.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
I tried using that logic but it didn't work. Let me give you an example of one of the lines that is messing me up.
The row contains these values from A1 to H1. Each line is a cell:
<br />
A1: "TE,ST"<br />
B1: ""<br />
C1: "<br />
D1: ,<br />
E1: ,<br />
F1: ,<br />
G1: "<br />
H1: "<br />
I drag that row onto my form and drop it. Now, when I set up and read from the stream I get this string to represent that row:
"""TE,ST""","",",",",",",",",","
If I hit a quote and keep reading until I hit another quote, I would get "" as the first element (when its really "TE,ST"). Also, single quotes (such as C1) are displayed as a single quote, and commas (D1 - F1) are displayed as ",". I cant just use quotes. How would I know if "," represents a "real" comma or its a quote char and the comma is the delimeter?
Should I not be using a stream to read in the data?
If you get a chance, write a small app to see what I mean. Drag the row I described. It'll probably be more clear than my explanation.
Any other ideas?
Thanks for the help,
-Flack
|
|
|
|
|
You can pick different clipboard formats (which are used both for copy and paste, and drag and drop functionality). Use ClipSpy[^] to see what other formats are available (they are string names) and see what data each contains. There may be an easier format for you to parse.
Applications will typically store many different formats for data each associated with a different clipboard format. You can pick whichever you like, and it's common to have a few fallbacks if an application doesn't pack a certain format into the IDataObject (which is actually a different implementation for both native and managed code, but represents the same thing).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Thanks for the help. I decided to try to get the values I need from the dropped Excel as XML.
However, when I try to iterate through the XML and extract the values I need, I'm not getting anything.
Here is a sample XML that I got form Excel:
<?xml version="1.0" ?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns ="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:html="http://www.w3.org/TR/REC-html40">
<Styles>
<Style ss:ID="Default" ss:Name="Normal">
<Alignment ss:Vertical="Bottom" />
<Borders />
<Font />
<Interior />
<NumberFormat />
<Protection />
</Style>
</Styles>
<Worksheet ss:Name="Sheet1">
<Table ss:ExpandedColumnCount="4" ss:ExpandedRowCount="1">
<Row>
<Cell>
<Data ss:Type="String">"TE,ST"</Data>
</Cell>
<Cell>
<Data ss:Type="String">""</Data>
</Cell>
<Cell>
<Data ss:Type="String">"""</Data>
</Cell>
<Cell>
<Data ss:Type="String">",,"</Data>
</Cell>
</Row>
</Table>
</Worksheet>
</Workbook>
Here is the code I tried to use to read it. (This is in my DragDrop event):
if (e.Data.GetDataPresent("Xml Spreadsheet") == true)
{
System.IO.Stream stream = e.Data.GetData("Xml Spreadsheet") as System.IO.Stream;
XmlTextReader message = new XmlTextReader(stream);
XPathDocument doc = new XPathDocument(message);
XPathNavigator navigator = doc.CreateNavigator();
XPathNodeIterator it = navigator.Select("Worksheet/Table/Row/Cell/Data");
while(it.MoveNext())
{
textBox1.Text += it.Current.Value;
}
}
This code doesnt work. The iterator returns a count of zero. Can you tell me what I am doing wrong? Is the xml doc not created correctly or is my expression used in the Select call incorrect?
Thanks for all of your help so far.
-Flack
|
|
|
|
|
And you won't get anything that way. The XML fragment includes a namespace which you must reference or else your XPath statement won't resolve the XML elements. Those XML elements (and attributes, for that matter, though most attributes are not namespace-qualifed) are defined by a namespace.
Unfortunately in the code you're using you cannot add an XmlNamespaceManager anywhere (oddly enough), so you might try setting XmlTextReader.Namespaces to false . This disables namespace support, but what that means from a programming standpoint I'm not really sure. I've never used this technique, before.
Normally, when you'd use something like XmlDocument.SelectNodes you'd first instantiate an XmlNamespaceManager from the XmlDocument.NameTable , add namespaces (with whatever prefixes you want; the prefixes themselves don't have to be the same as what's in the XML document), then select using an XPath expression utilizing the prefixes that match up with the same namespaces that qualifies any elements and attributes as necessary.
A word of caution, too: Excel - beginning with XP, IIRC - only started using XML as a clipboard format. Older Excel versions do not so if you intend supporting older versions of Excel either by interop'ing with an older typelib or not using new functionality from the newer typelib (since COM, when implemented correctly - and Office is a shining example of those rules, does not change published interfaces and typically remains backward compatible) you should not use the XML clipboard format.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hello
i am unable to call Uninstall method during Uninstallation..
what all I did that i made 2 seperate projects for both Install and Uninstall and add respective DLLs in INSTALL and UNINSTALL custom Actions,this is the code which i use for Uninstall and this is saved as seperate .dll file which then used in Custom Actions->Uninstall section
public override void Uninstall(System.Collections.IDictionary savedState)
{
//Remove XML FIle
MessageBox.Show("i am in Uninstall","Config File");
if(File.Exists("c:\\_config.xml"))
{
File.SetAttributes("c:\\_config.xml",FileAttributes.Normal);
File.Delete("c:\\_config.xml");
MessageBox.Show("File is Deleted","Config File");
}
base.Uninstall(savedState);
RegistrationServices regsrv=new RegistrationServices();
if (!regsrv.UnregisterAssembly(this.GetType().Assembly))
{
throw new InstallException("Failed To Unregister for COM");
}
}
UNinstaller is not calling this method at all,kindly guide me,right now i am not sure that whether i need 2 seprate Dlls for 2 different custom actions(Install and Uninstall) or by putting both overridden methods in a single dll and then call them in "Install" and "Uninstall" Sections of Custom Actions?
|
|
|
|
|
You should keep your installer all in the same assembly. Not only is this a better design that uses less space and is more easily maintained, but it's also necessary because into that savedState dictionary is data that is serialized (using the SOAP formatter) with Type information, which means that the fully-qualified type name (namespace + class), the assembly it's in, and the assembly information like the version and public key token, are all serialized. Since you defined your installer in a separate assembly, that Type information would not match. When the dictionary is deserialized the formatter would throw an exception.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Heath
Thanks for reply..
let me clarify you that Install method has been working fine,as i mentioned in my previous post that i made an assembly dll and associated it with Install Custom action,i now put Uninstall method in same project/assembly where Install method is,for testing i ran InstallUtil utility on my dll and it successfully called both Install and Uninstall method,like
i called Installutil Registry.dll and Installutil /u Registry.dll and they are bringing up respective method properly..
Heath,can you be a bit more elaborative?specially,which CustomAction should I use to call Uinstall method?
Thanks
-A
|
|
|
|
|
Actually, I believe you should elaborate. The way your first post reads seems to say that you had two projects for one installer assembly. And mentioning "CustomAction", I assume you're trying to get an assembly to run from within a Windows Installer project? You didn't mention Windows Installer before. Please be specific in your details of the problem; otherwise, it's difficult to help you.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
I am sorry if there was some confusion..let me try to elaborate step by step
1)I added a class library project in my Solution(.sln) and wrote both Overriden versions of Uninstall and Install and built them in form of dll(e.g:mySetup.dll) assembly
2)in the Setup Project,which is also in same solution,i added my mySetup.dll in FileSystem-><i>Application Folder
3)After that i associated that mySetup.dll in Custom Actions(Install and Uninstall) and built the Setup project.
the setup is calling Overriden Install method but not Uninstall method
as you mentioned I assume you're trying to get an assembly to run from within a Windows Installer project?
i think "Yes" because the assembly is called when the Setup.msi file is executed.
Hope i explained a bit better,sorry for my ignorance
-A
|
|
|
|
|
Make sure that for everywhere you use the assembly with the Installer class derivative you have the property "InstallerClass" set to "True". This property can be found in the PropertyGrid when you have your custom action selected.
How are you determining that when you uninstall the MSI package that your Uninstall method isn't executing? Custom actions are difficult to debug (it's one of the things I do at Microsoft), and do keep in mind that the install state files are often left behind.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|