|
Thanks for the reply and for giving an interesting insight in how to set things up in a light-weight fashion. I'll investigate this option for sure but first I'll try the Region/Clip options.
|
|
|
|
|
Hi!
I'm implement my own calendar class derived from System.Globalization.Calendar.
I need to make my calender with more that 12 months in a year (say 16). But then I use the DateTime(int year, int month, int day, int hour, int minute, int second, int millisecond, Calendar calendar), it givs me a ArgumentOutOfRangeException. The parameters states that month is 1 through the number of months in calendar and day is 1 through the number of days in month. There is the problem how do I define my own calendar class so I can set ex. DateTime(1800, 15, 10). I thing that DateTime use the abstract mathod ToDateTime(...) to deliver a instance.
May help:
http://www.abgeen.com/JalaliCalendar.cs[^]
http://www.cs.oberlin.edu/~jwalker/calendarReform/GlobalCalendar.cs[^]
Best regards, Gywox
|
|
|
|
|
What's the best way to validate a filename?
In my UI, the user must enter a filename in a Forms.TextBox control.
This would be for a new file for saving data, so checking if it exists is of no use.
I can override the OnValidating event, but what chars do I look for?
Kathy.
|
|
|
|
|
The Path object has an InvalidPathChars property. Look for that in the user-entered string like so:
if(myPath.IndexOfAny(System.IO.Path.InvalidPathChars) == -1)
{
}
Picture a huge catholic cathedral. In it there's many people, including a gregorian monk choir. You know, those who sing beautifully. Then they start singing, in latin, as they always do: "Ad hominem..."
-Jörgen Sigvardsson
|
|
|
|
|
Hi all!
I am writing an windows application using MySQL as the source database. Can anybody tell me how to get the datarow when I select some specified rows from the database please? I try to use the following way to do that, but it doesn't work:
<br />
string commandtext = "select * from machine where price = 100;";<br />
OdbcCommand command = new OdbcCommand(commandtext, connection);<br />
OdbcDataReader reader = command.ExecuteReader();<br />
ArrayList row = new ArrayList();<br />
int i = 0;<br />
while (reader.Read())<br />
{<br />
row.Add((DataRow) reader.GetValue(i++);<br />
}<br />
reader.Close();<br />
Could anybody tell me how to solve this please!!!
Thanks in advance!!!
Asura
|
|
|
|
|
OdbcDataReader.GetValue gets the column specified by the ordinal you supply. So reader.GetValue(i++) only returns one column and if you have multiple rows (more rows than you have columns) you will probably find that your code throws an exception once i is greater than the number of columns in your database.
If you want all the columns you need to use GetValues which will fill an array with all the column values you have.
The easier way to do this though is to use a DataTable.
Also, if you're using MySQL you could consider downloading and using the MySQL Connector for .NET (http://dev.mysql.com/downloads/connector/net/1.0.html[^])
|
|
|
|
|
You can't get DataRow objects from a DataReader. If you wan't DataRow objects, use a DataAdapter to fill a DataSet.
---
b { font-weight: normal; }
|
|
|
|
|
Hi
I have a mainform that opens up another form 'A'. By doing something on form 'A', opens up form 'B'. Both forms 'A' and 'B' should have access to the instance and fields of the mainform. What is the best approach? This is not MDI. Should it be? Can MDI be avoided in this case?
|
|
|
|
|
One way is to have each opening form pass an instance of itself to the form it opens and have that new form store that instance. If you want to access you form class's methods and properties, define the field in the new form as the type of your form and not simply Form (otherwise you'll have to cast your field to the right type before calling non-overridden methods and properties).
Such a property does already exist and allows owned forms to be minimized and restored along with the owning form. Read the documentation[^] for the Form.Owner property for more information.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
I have a two part problem, I'm currently working on.
I have some code which will capture a screenshot of a window, based on the window handle.
However, I don't know how to get the window handle of windows external to my application. Anyone know a simple way to do this? It would be very helpful if I could just simply retrieve an array of all the window handles belonging to windows currently open (minimized or maximized).
I also need to know how to simulate a mouse click in an external window, if I know the window handle.
Thanks!
|
|
|
|
|
You can either enumerate top-leve windows by P/Invoking EnumWindows , or simply use Process.GetProcesses like so:
foreach (Process p in Process.GetProcesses())
{
if (p.MainWindowHandle != IntPtr.Zero)
{
}
} To simulate a mouse click, you can get a window handle (from a top-level window handle, P/Invoke FindWindowEx[^] and post WM_LBUTTONDOWN and WM_LBUTTONUP , which you can find the values for in the Platform SDK.
You could also P/Invoke SendInput[^]. For further help on that, see the Platform SDK on MSDN[^] or search this forum for "SendInput". I have posted this solution a couple of times that I can remember in the past.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
I think that's the fastest response I've ever recieved on these forums. And a VERY helpful response. Thank you VERY VERY much.
|
|
|
|
|
After looking at this method for about a day, I've realized it will not do what I need. Using the process object returns processes - and I need applications, that are not listed in the process list. Not just applications, but the window handles to all the windows that are urrently open on the desktop; many applications have more than one window open at a time, I need them as well.
|
|
|
|
|
i've added to my application a setup solution.
I've got all the standard form that visual studio made automatically.
If i want handle the main function of the form n°1 or handle the click of the button... how can i do?
|
|
|
|
|
Hello everyone,
I am currently working on this project, and I need to read in a dbf file and parse it as well. But I cannot do it without some driver or something like that. I was wondering what driver it was to read in the file because I have been searching for it on the internet but I cannot find much information on the subject.
Thanks,
TheMajorRager
|
|
|
|
|
If you need to read and parse the file, then use a FileStream . If you want to open and use it as a database file for ADO.NET, use an instance of OleDbConnection with the appropriate connection string to point to the file. The System.Data.OleDb namespace classes allow you to use any OLE DB driver, and there is for DBase files.
To get the correct connection string, you can create a new connection in the Server Explorer in Visual Studio, select the DBase OLE DB provider, and browse to the file. I recommend in shipping code, however, that you make at least the file path a configuration variable in the app.config file since a user may place or move the dbase file elsewhere on their drive or on the network.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Thank you for replying! My problem is that when I open the file however, I want my program to use the comma as a delimiter, is there a way to convert a dbf to a csv file, because I want to parse the file, but I cannot parse it the way I can with a csv or exp file.
|
|
|
|
|
Sure you could parse it - it's just a file. How you parse it (i.e., understanding the file structure) depends on the dbase format with which I'm not familiar. There's probably a lot of resources on the web about this, however.
The big question is why you want to parse it? If you want to run SQL statements on it, fill DataSet s, etc. - all the stuff you'd normally do with any other database - use the OleDbConnection with the correct connection string for the dBase OLE DB provider and to specify the path to the file and any other properties that dBase supports.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Nevermind, you were right, I need to use the OleDbConnection. I am trying to use that but when I try to open the .dbf file I get an error message, saying it is not a valid database.
-- modified at 19:33 Wednesday 5th October, 2005
|
|
|
|
|
Nevermind, I figured it out, thanks a lot!
Sincerely,
TheMajorRager
|
|
|
|
|
Hi,
I have a groupbox with number of checkboxes in a form.
I want only one check box being checked at a time (just like radio buttons)
How do I do that. Thanks.
|
|
|
|
|
Why not use radio buttons?
To make checkboxes exclusive is not very user friendly, as that is not the normal behaviour of checkboxes. Radio buttons on the other hand always work that way, so the user would know what to expect.
---
b { font-weight: normal; }
|
|
|
|
|
You should use RadioButton s, then, within the same container control. Not only do they already provide the functionality you want, but it gives the user a consistent experience which is very important for applications. Great care goes into creating Windows and Windows applications to make sure users have a consistent experience. ISVs should follow these guidelines as well.
If you have a legitemate reason for using CheckBox es, you'll have to clear them yourself. I recommend writing a separate class that uses a list with you can add CheckBox es to and then have methods to clear all except the one that was checked. You could also simply enumerate all controls in your container using the Control.Controls property and - if the current enumerated control is a CheckBox and it's not the one that was clicked, clear the check mark. It also allows you to logically group differnet check boxes even if they're in the same container or different containers.
The former - using a separate class - is more flexible and scalable. A simple example follows:
using System;
using System.Collections;
using System.Drawing;
using System.Windows.Forms;
class CheckBoxManager
{
ArrayList cbs;
bool changing = false;
public CheckBoxManager()
{
cbs = new ArrayList();
}
public void Add(CheckBox cb)
{
if (cb == null) throw new ArgumentNullException("cb");
cbs.Add(cb);
cb.CheckedChanged += new EventHandler(OnCheckChanged);
}
public void AddRange(IEnumerable cbs)
{
if (cbs == null) throw new ArgumentNullException("cbs");
foreach (object obj in cbs)
{
CheckBox cb = obj as CheckBox;
if (cb != null) Add(cb);
}
}
void OnCheckChanged(object sender, EventArgs e)
{
if (changing) return;
else changing = true;
foreach (CheckBox cb in cbs)
{
if (sender != cb) cb.Checked = false;
}
changing = false;
}
}
class Test : Form
{
static void Main()
{
Application.Run(new Test());
}
Test()
{
CheckBoxManager group0 = new CheckBoxManager();
CheckBoxManager group1 = new CheckBoxManager();
int top = 8;
for (int i = 0; i < 10; i++)
{
bool isgroup0 = i % 2 == 0;
CheckBox cb = new CheckBox();
if (isgroup0) group0.Add(cb);
else group1.Add(cb);
Controls.Add(cb);
cb.Text = string.Format("CheckBox{0} (Group {1})", i, i % 2);
cb.Top = top;
cb.Left = 8;
cb.Width = 200;
top = cb.Bottom + 8;
}
Height = SystemInformation.CaptionHeight + top;
Text = "CheckBoxManager Example";
}
}
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi,
I want to sublty allert my user to missing data with a visual prompt slighlty more stark than the basic "(null)" given by a data grid. Ive changed the message with a custom colomn style BUT i want to make that message bold and a different colour.
Is there an easy way to achive this using settings?
Thanks.
-- modified at 12:59 Wednesday 5th October, 2005
|
|
|
|
|
For a DataGridTextBoxColumn you can access the embedded TextBox using the DataGridTextBoxColumn.TextBox property. If you want more control - such as encapsulating the data logic for displaying text differently based on the current value - implement your own DataGridColumnStyle and draw the text and background as you want in your DataGridColumnStyle.Paint override.
There is at least one example of this here on CodeProject. Please search the articles using "DataGridColumnStyle" and you should find it.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|