|
You can use DataGridViewButtonColumn to add buttons to your gridview. Then, handle its click event to insert/delete rows.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
This question has been answered so many time and so well covered this may help you[^]
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I'm back at it, trying to build an app to manage substation equipment. I had to take a little break to design a substation and some new sewer plant motor control circuits, but I'm back at it and still confused. Before you tell me to read a book, I have read two, and ordered another. But the third book won't arrive until Friday, and I have a five day weekend for the Thanksgiving holiday I'd like not to waste. I've also reduced the scope of the problem to manage one kind of device, instead of tackling 4 different types with entirely different information to manage. I figure that if I can get one to work, it won't be nearly as hard to expand as it would be to write it all at once.
I have a SQL Server DB with several tables - a master that holds equipment information that is invariant, a status table that holds information about the current location, last service date, and number of operations since last service, and a pair of tables to hold the histories of readings taken and services performed on each device. I have created a boilerplate app with a main form, and that form has a menu to allow the user to Add, Edit, Move, Service, Read, or View devices. I know this is easy to anyone who does it all the time, but I am well and truly stuck for ideas about where to go from here.
I've tried before to use a sequence of forms, hiding and showing them, to walk a user through a few pages of data entry, but it turned out to be problematic to transfer the data between forms. I've tried using dialog boxes for each step, but had similar problems. I tried using data-bound controls on each form but that quickly became a nightmare, so I'm leaning toward a solution that has the main form collect all the data, then pass it off to functions that update the database. Besides, I believe the separation of data functions and user interface makes good sense from a maintenance point of view.
Is this a place where a MDI is appropriate? Or is the idea of using multiple forms in sequence a better approach? Or should I stick with one form and change the visibility of controls as the user moves through the process. I'm lost here. I think the question is one of architecture, rather than procedure or actual coding, but I don't know if I'm even asking the right questions yet. I've read lots of stuff about making and using forms, but not one example of using two or more in the same app has appeared anywhere I've searched. That leads me to believe that I'm barking up the wrong tree entirely, and there's some secret method used by almost every modern program I've used that isn't written up anywhere. Any book can tell me how to make a form, and I have several that do, in multiple languages. But not one of them mentions movingsfrom form to form, persisting data along the way, until the time comes to save the data from all of them.
Can someone get me started? Pretty please...
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
Wrong forum so consider yourself .... Excoriated, where the bloody dictionary when I need it.
The is definitely a design issue and we all have our favourite flavours. Here is mine, caveat most of my apps a batch management so no transactions to speak of.
Main form with a navigation control on the left, menu for methods not based on a specific piece of data (exit, process, help and reports), an icon strip for CRUD keys
Changing selection in the nav control populates a list in the main body of the form. From the list you pop a dialog ALWAYS, never edit in a list control. You can either pass an ID or an object to the dialog in the constructor. Your list has the ID of the records you want to work with so I pass that to a dialog designed to work with that object.
When the dialog is opened it inspects the ID passed in, if you passed a 0 (ADD) then it gets an empty datatable from the database, if there is an id (EDIT) then it gets that record from the database. The class that gets the datatable (designed for that object) also populates the object. I then bind the form to the object. When the user edits the form the data is passed to the object via the binding.
When the user saves the dialog I write the data back to the database and return DialogResult.OK to the main form and closes.
Main form detects the OK and reloads the list control with the new record.
I rarely need more than 3 levels of nested dialogs for any operation.
BTW, Last Serviced date is redundant on the Tool table, Select top 1 from service table should do it. Otherwise you need to reconcile between the last service field and the service table, what happens if someone deletes a service record?
|
|
|
|
|
Thanks for some excellent advice! It actually makes sense to me.
One of the approaches I first considered was to make a master page that spawns dialog boxes to collect information, then passes the result back to the main form. I forget why I abandoned it.
As for the forum choice, my other choice was general programming, and it had more cobwebs than visitors last time I looked.
About the last service date... I had planned to update a device status table with that info every time a service is performed in order to provide a concise, small table that I can use to give users a quick, easy report to show which devices are nearing a service appointment. If a service record gets deleted, no big deal - the critical data is recorded elsewhere. Similarly, whenever a new reading for the operation counter of a device is entered, it's cumulative operations since the last service will also be stored in the status table. These devices are good for about 50 operations before they fail if service is not performed, so this information has to be really easy to find. At $18,000 each, we don't keep many spares on hand, and can't afford to lose one!
BTW - My new book arrived today - Programming Microsoft SQL Server 2008 - and it looks fairly complete. All the code is written in C#, too, rather than the VB I don't have any interest in learning at the moment. It's looking to be a fun weekend!
Thanks, again!
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
Roger Wright wrote: it had more cobwebs than visitors
True, the reason you got a sensible reply (although posting here is the reason there is bare)
The reason NOT to use the service date on the tool record is that it sets a bad habit and will lead to disaster, sooner or later the auditing of the related data is going to be critical and if you have it in 2 places (tool and service) then reconciliation is an issue. This is a BASIC tenant of database design, called normalisation, no data should be stored in more than one place. There are exceptions but they are EXCEPTIONs.
|
|
|
|
|
|
i have windows form (.net 3.5) and have to access data from database that is located on a remote server. how can i do it? plz help. can i do it with webservice. if yes then tell me how to access the webservice.
Thanks!!!!!!!
|
|
|
|
|
Just as you would do for the local one. Write the connection string and use its Open method. Just make sure your database allows remote connection.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
DON'T ask the same question in multiple forums. Identify the most appropriate forum for your question and post it ONLY there.
|
|
|
|
|
Thanks in advance
is their any way to resize form and controls according to Screen resolutions without much hassle means instead of changing controls positions ans sizes manually , like in java their are scripts can we do it in vb.net
Best Regards,
SOFTDEV
If you have knowledge, let others light their candles at it
|
|
|
|
|
Learn the art of docking and padding of controls.
I believe there are articles about it and once you learn it, it is not a hassle.
|
|
|
|
|
i am not asking about form resize event like maximize or normal , i want screen to adjust in different resolution 1024 x 768 or 800 x 600 etc , like shrink or grow adjust according to resolution
Best Regards,
SOFTDEV
If you have knowledge, let others light their candles at it
|
|
|
|
|
Hi, I am not sure that I get you right but if you want your application to change screen resolution : change screen resolution C#
As for the shrink or grow, thre is the Form.AutoScaleMode which I haven't worked with.
|
|
|
|
|
Use TableLayoutPanel. It is a great control to manage these kind of things. Make sure that:
1. Columns and rows have their heights and widths in % wherever required.
2. All the controls are anchored to all the sides of cell in which you keep them.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
Using C# 3.5 I develop a WinForm application that should mimic a word processor, e.g. allow users to type text, insert images and tables and apply certain formatting styles to them. Then I need to parse the text, replace certain variables with data from a database. merge multiple 'documents' and create output in at least PDF and possibly either DOC, RTF or HTML.
At first I thought this shouldn't be hard: there are so many commercial and open source components available. At least one of them should fit my needs. But I seemed wrong about that: I cannot find any suitable technique that allows me to do all this without bugs or too much complexity. For instance:
I've tried RTF:
.net RichTextBox control cannot adjust the table's width, nor would I like to search/replace rtf-fieldcodes to add data driven content.
TX TextControl seemed like a good choice, but it is a wrapper around some native win32 dll that has it's limitations as well (conversion / resizing / drawing issues).
TE Edit has buggy table-support
PinEdit uses Internet Explorer (I don't like dependencies to Internet Explorer)
DevExpress has no table support in their RichEdit component
That's when I thought I would like to separate content and layout and use an officially accepted standard for that. So I looked at XML-authoring components such as XMetal and Syntext Serna, but they seem offer much more than I need (such as workflow), complex to configure and embed and don't fit the skin in my application.
After all this I've seem to have hit a brick wall.
Can anyone give some advise, leads, directions or best practices?
|
|
|
|
|
Hi All,
I have a problem with the FolderBrowserControl. When I use the FolderBrowserDialog in my application on a Windows Server 2008 system a strange behaviour can be recognized. If I open the dialog the first time it is displayed the way it should.
When I open it a second time, the tree control looks different. The plus signs aren't displayed any longer. Instead only blank squares are displayed (Sorry for not attaching a picture. But I don't have a server where I could put it...)
This behaviour can't be reproduced on Windows XP, it only occurs on Windows Server 2008 systems.
The control is created in a separate class and is opend from a grid.
//as special folder the desctop is used
public MyControl(Environment.SpecialFolder folder, bool createFolder)
{
m_IsModified = false;
m_FolderBrowser = new WinForms.FolderBrowserDialog();
m_FolderBrowser.ShowNewFolderButton = createFolder;
}
//this method is executed from the grid
public WinForms.DialogResult ShowDialog(WinForms.IWin32Window window)
{
WinForms.DialogResult ret = m_FolderBrowser.ShowDialog(window);
m_IsModified = (ret == WinForms.DialogResult.OK);
return ret;
}
public void Dispose()
{
m_FolderBrowser.Dispose();
m_FolderBrowser = null;
}
I really don't have any idea why this problem occurs and how to solve it. I hope you can help me.
Thanks.
Best Regards,
Viola
|
|
|
|
|
The symptoms you mentioned usually occur in applications when it is too tight on memory, typically caused by memory leaks. Check if the control has any known issues and if it is supported on all platforms.
|
|
|
|
|
Hi Shameel,
thanks for the tip. It really seems to be a memory leak. But it has nothing to do with the folder browser dialog. The leak probably occurrs in another referenced dll.
Best Regards,
Viola
|
|
|
|
|
i want to drag a control and drop it on some other position in the same form window. can any body please help me on that.
|
|
|
|
|
|
Hint: Use the MouseDown , MouseMove and MouseUp events and change the Location property of the control.
modified on Tuesday, November 17, 2009 10:36 AM
|
|
|
|
|
I wrote something like this back in the day and I will look for it. But dragging controls is very demanding since they redraw all the time causing flickering and bad performance (at least in .net 2.0).You can show squares when you drag or implement it by adding custom redraw on bitmaps which may still cause problems, very complicates and has relatively poor performance.
This is a big task and you should be looking for a nice peace of code to start with.Try looking for a custom drawn object source code it will be a good start.
I don't know whether you should use an off the shelf product, check quality and pricing first.
I found this here : Drag and Drop Image C#
|
|
|
|
|
I am using Visual C# Express 2008 SP1 on Windows Vista will all the updates applied. No matter what I try, I can't open some inherited forms (if I am even using that term correctly) in the Forms Designer. But my project builds just fine! I am going nuts not being able to design my forms. I am having trouble because I re-did my project's namespaces and maybe the designer is getting confused.
The form I want to open is in the 'Windows' namespace (something I made up, i.e. MyProject.Gui.Windows) and the baseform and its base are in the 'Docking' namespace as in MyProject.Gui.Docking and I think it is because my namespaces must somehow be retarded is why I am getting the error:
at System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.EnsureDocument(IDesignerSerializationManager manager)
at System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager manager)
at Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager serializationManager)
at System.ComponentModel.Design.Serialization.BasicDesignerLoader.BeginLoad(IDesignerLoaderHost host)
I am also doubly confused becuase my code builds just fine. My code is as follows:
baseform of the baseform:
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics;
namespace MyProject.Gui.Docking
{
public class DockContent : Form, IDockContext
{
public DockContent()
{
InitializeComponent();
}
}
}
The baseform of the baseform (above) has no .designer.cs file. It is part of the WeifenLuo.Docking library. I subsumed the library directly into my project's namespace structure so I don't have to lug around DLL's. I can view this baseform of the baseform in the designer just fine.
Now on to its first-level derived form ToolWindow .
i.e., the code is
using System;
using MyProject.Gui.Docking;
using MyProject.Core;
namespace MyProject.Gui.Windows
{
public partial class ToolWindow : DockContent
{
public ToolWindow()
{
InitializeComponent();
}
...
}
}
Notice how I derive from DockContent class which is in the Docking namespace but my child form is in the Windows namespace. I tried putting the child class also in the same namespace but the child form still would not design.
But changing the namespaces doesn't do anything! Even if all the forms in the hierarchy are still in the same namespace the Forms Designer still craps on me. I suspect I am being completely retarded about something but I can't figure out what. Any help would be appreciated.
Sincerely Yours,
Brian Hart
|
|
|
|
|
Hello,
I'm working on Windows application c#
i have form1 which contain data gridview to view the content of table from sql database.
i've enabled edit, delete in the gridview, and then i've added two queries one for update and the other for delete through MyDataSet1.xsd page.
now after updating and/or deleting any record i wanna click on a button to confirm user that the operation done. but i don't know how to save updating or deleting!!
any help guys?
|
|
|
|
|