|
After 4 or 5 years in the ASP.NET world I'm about to embark on a new LOB WinForms application and I wondered what the current thinking was in terms of GUI design and implementation?
Any suggestions? I'm severely lacking in inspiration at the moment
Cheers
James
|
|
|
|
|
Look at other applications. I'm doing a very small POS application, so I downloaded MS Office Accounting Express; it's free. Then I looked at the layout of their invoice screen, said I like this but I don't like that, and quickly came up with my own. It's not copying, just looking for inspiration.
|
|
|
|
|
I am using visual inheritance which is really helpful to create uniform design between forms.
|
|
|
|
|
I have several ComboBoxes on a form that are bound to BindingSources. The only code I have is code to set their SelectedIndex properties to -1, to force the user to make a selection, in favour of accidentally using the first item in a list. This code has no effect in my form's Load event, so I have been forced to start a Timer at the end of the Load event, and then on the Timer's Click event, set the SelectedIndex properties. Can anyone explain this, and maybe offer a more elegant solution?
|
|
|
|
|
Insert an "empty/null row" as first item in your source, instead of using -1 to signify value not selected. Have the UI to verify that the combo box has value selected before you save it.
|
|
|
|
|
That was one of my options, but I find setting SelectedIndex a bit tidier that messing with the list domains. Alternatives in this direction are inserting the null value programmatically though, then I would be more comfortable working with an unchanged data source. I would do that in a derived ComboBox control, overriding one of the data binding methods.
I will eventually do that anyway, as I also want a 'Create a new <entity name="">...' as an option in all my drop-downs as well. This must also be 'artificially' inserted and trigger an event that tells the Combo's container to initiate the Create action for that entity.
|
|
|
|
|
By inserting the empty/null row, i mean programmatically, not into your data.
By the way, the user won't be able to unselect a selected combobox item, if SelectedIndex = -1 method is used, right?
|
|
|
|
|
Yes, but I don't have any code where I populate the lists, where I can inject another entry. If I did, I would have, but as it stands, simply setting SelectedIndex to -1 seems less complicated for extra code than inserting a list item.
|
|
|
|
|
This is a known bug in the WinForms combobox. Try setting SelectedIndex = -1 twice (don't ask...)
It has become appallingly obvious that our technology has exceeded our humanity. - Albert Einstein
|
|
|
|
|
Hi all,
pls help me
in my application using C#.net (window form) i need to save a .txt file. but if the same filename exist i need to save it as a new filename.
i have searched in net but could only find deleting existing or overwritting on the file.
pls help to get some solution
|
|
|
|
|
u can use GUID(Global Unique Identifier) for saving the text file with unique name
|
|
|
|
|
One very simple approach I take is simply create a while-loop that increments an integer, appends it to the filename (without the extension, of course), and checks for existence (after re-appending the extension). So long as that filename exists, I increment the variable again and try the next number.
Remember to include a failsafe in case the loop accidentally runs forever. Limit it to 10 or 100 iterations for example. I suppose a for-loop would be more convenient in this case then, but a while loop is more syntactically meaningful.
It has become appallingly obvious that our technology has exceeded our humanity. - Albert Einstein
|
|
|
|
|
One of the System.IO classes, I think it is Path, has a method that returns a unique file name.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi
I have a main form which opens a thread that opens a new form.
in the new form i'm trying to open an OpenFileDialog.
when i'm trying:
"if (projectFormOpenFileDialog.ShowDialog() == DialogResult.OK)"
when running at debug mode i'm getting:
"Current thread must be set to single thread apartment (STA) mode before OLE calls can be made. Ensure that your Main function has STAThreadAttribute marked on it. This exception is only raised if a debugger is attached to the process..."
i have declared [STAThread] in the mainform function that opens the new form, also on the event that invokes the openfiledialog function.
help on this will be most appreciated
thanks,
Yohay
|
|
|
|
|
OpenFileDialog cannot be shown from any thread other than your main GUI thread. You cannot open it from a background thread. You'll need to change your program accordingly (and by the way, you shouldn't be showing other forms from background threads, either).
It has become appallingly obvious that our technology has exceeded our humanity. - Albert Einstein
|
|
|
|
|
many thanks for your help.
y
|
|
|
|
|
I have a parent child relationship, on DocumentID, between an invoice and invoice lines. A form displays invoice fields and has a grid for invoice lines. The grids BindingSource points to the Invoice Binding Source, and it's DataMember to the relation, so I think this is correct.
Now, if I leave the relation type to Only Relation, the DocumentID in my new Invoice is -1, and the DocumentID in my Invoice Lines grid is also -1, but the Line record remains -1 after being written to the database. So, I think maybe I should make the relation a constrain as well and add a cascade update, but then I get an error that -1 doesn't exist in the parent table, even though the Invoice datatable DocumentID is -1.
|
|
|
|
|
With an XmlDataDocument (based on a DataSet and an XmlDocument) and a BindingSource, I've found that I have to add a handler to AddRow for the child and wire up the child's FK to the parent manually. Don't know if that helps in your case.
However, obviously (or it should be obvious) the invoice DocumentID has to exist. If you're using identities, you'll have to save the invoice row first, get the DocumentID, put it into the invoice line FK's, and save the invoice lines.
Marc
|
|
|
|
|
Hi Mark, thanks for the advice, but as I have it, establishing a DataRelation between the two tables should be enough for ADO.NET to know to cascade the new parent primary key value to the new child records.
In fact, it is enough, but I have to call EndEdit after calling AddNew on my parent binding source. This makes the -1 PK availble to child FK, and the relation is established. Now when use the table adapters to update my DocumentTable and then DocumentLine table, the automatic cascade of the PK to the FK works perfectly.
|
|
|
|
|
Brady Kelly wrote: but I have to call EndEdit
So that was what was missing?
Brady Kelly wrote: Now when use the table adapters to update my DocumentTable and then DocumentLine table, the automatic cascade of the PK to the FK works perfectly.
Huh. That's pretty impressive. I've never actually seen that behavior--I'll have to revisit some code I recently finished where I had manually assign the FK. It'd be useful to reduce this whole issue into a small, simple, test case.
Marc
|
|
|
|
|
What is the best way to do this? Implement the content forms as controls, and factor the commonalities out into a host form, or to inherit from a base form. Somehow I think the latter is not as simple as it sounds, but I haven't tried either yet, I'm just checking.
|
|
|
|
|
Hi Brady,
if you need a number of forms all sharing some characteristics or capabilities, it seems
logical to me to define such a specialized form class, then instantiate it (or one of
its derivatives). That is OO for you.
If on the other hand, the commonality is not in the form itself, but rather in the
objects (Controls) it contains, creating one or more UserControls may be the way to go;
in this case, the form isn't anything special, you mainly make it easier to populate it.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Well, the forms all share a common layout, toolbar, and menus, so my consdered options are to write a base form with those, inherit, and override some methods use by those, or to write a host form like that for content controls, and expose a generic interface on the controls to react to the interface of the host form.
|
|
|
|
|
Seems it is all about overall aspects such as look-and-feel, and not specific content.
So I would go with the specialized form and derive more forms from it.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
hello
i m having a timer event which runs on after 1 minute
in my project i m having the appointment details...so it throws a message that u r having appointment on this time with this person before a particular time(depends on user)..so for this i use a timer event like...
void myTimer_Elapsed(object sender, ElapsedEventArgs e)
{
strCon = strCon.Replace("CONNECTIONSTRING", "Data Source='D:\\Neetu\\Training\\My_Diary_Database.mdb';Provider='Microsoft.Jet.OLEDB.4.0';Jet OLEDB:Database Password='neetu';");
con = new OleDbConnection(strCon);
query = "select alertSetting from settings where ID1=1 ";
cmd = new OleDbCommand(query, con);
con.Open();
dr = cmd.ExecuteReader();
if (dr.Read())
{
setting = Convert.ToInt32(dr["alertSetting"]);
}
con.Close();
dt1 = System.DateTime.Today.AddDays(3);
dt = System.DateTime.Now.AddMinutes(setting);
appointment_reminder(dt, dt1);
}
private void appointment_reminder(DateTime addTime, DateTime Time)
{
int i=0,check = 0;
string appointQuery;
DateTime newdt = addTime, newdt1 = Time;
con = new OleDbConnection(strCon);
DateTime dt = System.DateTime.Now;
string dtToday1 = newdt.ToString("MM/dd/yyyy hh:mm:00 tt");
string dtToday = dt.ToString("MM/dd/yyyy");
appointQuery = @"SELECT * FROM appointment WHERE Apntmnt_date=CDate('" + dtToday + "') and Apntmnt_time = CDate('" + Convert.ToDateTime(dtToday1) + "') order by Apntmnt_time";
cmd = new OleDbCommand(appointQuery, con);
con.Open();
if (con.State.ToString() == "Open")
{
dr = cmd.ExecuteReader();
while (dr.Read())
{
check = 1;
string myTime = dr["Apntmnt_time"].ToString();
strName = dr["Apntmnt_Person"].ToString();
strplace = dr["Apntmnt_Place"].ToString();
i++;
DateTime currentTime1 = Convert.ToDateTime(myTime);
string strTime1 = currentTime1.ToString("hh:mm");
DateTime currentTime = System.DateTime.Now.AddMinutes(setting);
string strTime = currentTime.ToString("hh:mm");
MessageBox.Show("Hello! You Are Having Appointment With " + strName + " At " + strplace + " On Time " + currentTime1);
}
con.Close();
}
}
my problem is this i want to know..m i doing right coz sometimes it gives the error that database connection state is connecting...n some thread problem....so help me...how shud i use this timer event..
|
|
|
|