|
Yes, there is such property of the Form class
|
|
|
|
|
You would handle the keypress event on the textbox, and if it's a return, you would call the method to close the form.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Using the AcceptButton property on the Form is much easier than this (as long as there is one single global AcceptButton for the Form).
-^-^-^-^-^-
no risk no funk ................... please vote ------>
|
|
|
|
|
Apart from that AcceptsReturn property of the textbox should (and it is by default) be false. Otherwise pressing Enter will insert new line in the textbox
|
|
|
|
|
Hi All,
Iam using Windows Datagridview...So iwant running time automatically ID has to generate.and one more think running time ID should not modify anything.and How to create a New row...So pls tell how to do...
Somasundaram
|
|
|
|
|
Hi Pls
How to delete the Rows through Wizard connection...
thanks
Somasundaram
|
|
|
|
|
Hi,
I am using Datagrid control in WinForms...So iam iam Using command buttons are Insert,Update,Delete,Cancel. so i need coding part for these commands Buttons.So pls help me. this Critical situation..Pls..
thanks
Somasundaram
|
|
|
|
|
Hi,
Below is the code snippet showing how we can insert, update and delete records using ADO.NET with DataGrid control.
-------------------------------------------------------------------------
BEGIN CODE
Private Const SELECT_STRING As String = _
"SELECT * FROM Contacts ORDER BY LastName, FirstName"
Private Const CONNECT_STRING As String = _
"Data Source=Bender\NETSDK;Initial " & _
"Catalog=Contacts;User Id=sa"
' The DataSet that holds the data.
Private m_DataSet As DataSet
' Load the data.
Private Sub Form1_Load(ByVal sender As Object, ByVal e As _
System.EventArgs) Handles MyBase.Load
Dim data_adapter As SqlDataAdapter
' Create the SqlDataAdapter.
data_adapter = New SqlDataAdapter(SELECT_STRING, _
CONNECT_STRING)
' Map Table to Contacts.
data_adapter.TableMappings.Add("Table", "Contacts")
' Fill the DataSet.
m_DataSet = New DataSet()
data_adapter.Fill(m_DataSet)
' Bind the DataGrid control to the Contacts DataTable.
dgContacts.SetDataBinding(m_DataSet, "Contacts")
End Sub
Private Sub Form1_Closing(ByVal sender As Object, ByVal e _
As System.ComponentModel.CancelEventArgs) Handles _
MyBase.Closing
If m_DataSet.HasChanges() Then
Dim data_adapter As SqlDataAdapter
Dim command_builder As SqlCommandBuilder
' Create the DataAdapter.
data_adapter = New SqlDataAdapter(SELECT_STRING, _ CONNECT_STRING)
' Map Table to Contacts.
data_adapter.TableMappings.Add("Table", "Contacts")
' Make the CommandBuilder generate the
' insert, update, and delete commands.
command_builder = New SqlCommandBuilder(data_adapter)
' Uncomment this code to see the INSERT,
' UPDATE, and DELETE commands.
'Debug.WriteLine("*** INSERT ***")
'Debug.WriteLine(command_builder.GetInsertCommand.CommandText)
'Debug.WriteLine("*** UPDATE ***")
'Debug.WriteLine(command_builder.GetUpdateCommand.CommandText)
'Debug.WriteLine("*** DELETE ***")
'Debug.WriteLine(command_builder.GetDeleteCommand.CommandText)
' Save the changes.
data_adapter.Update(m_DataSet)
End If
End Sub
END CODE
-------------------------------------------------------------------------
You may make some more enhancement in the code. For example, you may check the DataSet's HasChanges method to see if there are any changes been made before you go to create a new SqlDataAdapter and SqlCommandBuilder. It may also be more efficient to save changes grouped by type: all inserts, all updates, all deletes. The basic program, however, is trivial and is perfectly adequate if the user won't make a huge number of changes.
Hope this helps .
Regards,
John Adams
ComponentOne LLC
|
|
|
|
|
Hi, new to C# but getting there, need help on the following:
I have a MainForm with three panels on it, top, left and bottom. When I click a button on the MainForm the left panel gets a new form displayed in it with buttons on it. What I need to know is how to I change the top panel's controls in the MainForm when this buttons are clicked on the SecondForm that is displayed in the LeftPanel on the MainForm.
Thanks
D.M
|
|
|
|
|
My application has one MDIparent (say MDIparent.cs) and a tool form (say mainform.cs).
A text box in the mainform.cs takes some strings as input and displays the resulting data on the form. There are thousands of strings that can be entered in the input field that give different data for that particular string.
After entering my first string in the mainform, i open a "new" form in the MDIParent (File-->New) to give me another window of form so that i can calculate data for a different string.
However, when i do that, the application seems to be over-writing the data of the new window onto the first form and vice versa.
My goal is to keep keep the data different for different strings, separate.
Is it a problem with MDIParent or form?
Can anyone give me an idea how can i make sure that the form only subscribes to the proper event on itself alone?
Thanks
|
|
|
|
|
This is a bit help for the people who needs to translate the tooltip text of the CRviewer buttons and the dropdown text of this, here it is:
<br />
public void Translate(CrystalDecisions.Windows.Forms.CrystalReportViewer cr)<br />
{<br />
foreach (Control control in cr.Controls)<br />
{<br />
if (control.GetType() == typeof(System.Windows.Forms.ToolStrip))<br />
{<br />
foreach (ToolStripItem item in ((ToolStrip)control).Items)<br />
{<br />
switch (item.ToolTipText)<br />
{<br />
case "Export Report":<br />
item.ToolTipText = "Exportar Informe";<br />
break;<br />
case "Print Report":<br />
item.ToolTipText = "Imprimir Informe";<br />
break;<br />
case "Refresh":<br />
item.ToolTipText = "Actualizar";<br />
break;<br />
case "Toggle Group Tree":<br />
item.ToolTipText = "Agrupar";<br />
break;<br />
case "Go to First Page":<br />
item.ToolTipText = "Ir a primera pagina";<br />
break;<br />
case "Go to Previous Page":<br />
item.ToolTipText = "Ver pagina anterior";<br />
break;<br />
case "Go to Next Page":<br />
item.ToolTipText = "Ver pagina siguiente";<br />
break;<br />
case "Go to Last Page":<br />
item.ToolTipText = "Ver ultima pagina";<br />
break;<br />
case "Go to Page":<br />
item.ToolTipText = "Ver pagina";<br />
break;<br />
case "Close Current View":<br />
item.ToolTipText = "Cerrar Informe";<br />
break;<br />
case "Find Text":<br />
item.ToolTipText = "Buscar texto";<br />
break;<br />
case "Zoom":<br />
((ToolStripDropDownButton)item).DropDownItems[0].Text = "Al Ancho";<br />
((ToolStripDropDownButton)item).DropDownItems[1].Text = "Pagina Completa";<br />
((ToolStripDropDownButton)item).DropDownItems[10].Text = "Personalizar...";<br />
item.ToolTipText = "Aumentar";<br />
break;<br />
default:<br />
break;<br />
}<br />
}<br />
}<br />
}<br />
}<br />
<br />
I hope you find it useful, due to the other way is coding the buttons,
|
|
|
|
|
Thanks
Best Regards,
Chetan Patel
|
|
|
|
|
Hi iam facing an error when iam using
file.copy(filepath,destinationpath,true)
It gives me an error:
File.Copy(filePath, ArchivePath, True) Run-time exception thrown : System.IO.IOException - The target directory already exists.
Any ideas
|
|
|
|
|
first check if the file already exists or not
File.Exists(path2)
if yes then prompt message if user reply yes
then remove it first and then copy
Best Regards,
Chetan Patel
|
|
|
|
|
Are both filepath and destinationpath parameters a fully qualified file name or is destinationpath just the target folder? File.Copy can only copy files, so both parameters need to be fully qualified file names.
Look at the File.Copy Method (String, String)[^] docs, specifically at the IOException information listed under the Exceptions section.
You will get this exception if an I/O error occurs (unlikely) or the destination already exists, which is what is happening here. You can either do a File.Exists test before the copy and only copy if the file doesn't exist, or use the File.Copy(String, String, Boolean) form and pass in true as the boolean value to indicate that you want to overwrite the file.
|
|
|
|
|
Hi Friends,
I have a DataGridView control with a DataGridViewComboBox column with some items in the combo box.
My requirement is to open a new form upon selecting a particluar item in the combo box column of a row.
Which event of the DataGridView is to be captured to get the item selected in the combo box immediately up on selecting the item?
Thanks in advance for some help.
Subrahmanyam K
|
|
|
|
|
hello
can anybody give me an idea how to create an undo function for my application control
plz regards
dghdfghdfghdfghdgh
|
|
|
|
|
If your control is already written, you've got a lot of work ahead of you. Adding an "Undo" feature isn't just a couple of lines of code. You've got to plan for this before you write a single line of code because it completely changes how your control works internally.
Google for "Command pattern" and start reading...
|
|
|
|
|
Take a quick look at this months voting articles and look for the generic Undo. That's a good starting point - although as Dave said, you really should have planned for this from the start.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Pete O'Hanlon wrote: Take a quick look at this months voting articles and look for the generic Undo
Dang it, Pete, you beat me to it. A nice article, I may add
"Try asking what you want to know, rather than asking a question whose answer you know." - Christian Graus
|
|
|
|
|
Hello,
I've never read any articles on what are best practices on designing WinForms (or desktop applications in general) that make heavy use of a database, specifically when the database is in the same computer as the application, does anyone have any good links?
Anyway, my main question is about connection opening/closing, is it a good idea to open and close a connection every time you query the database? or is it better to open the connection when the form loads and then close it when the application closes?
What if the database is in a different computer? in my short experience it seems like only the first time you open the connection it can take some time, after that it seems to be instantaneous.
Any tips or recommendation in this area would be greatly appreciated.
|
|
|
|
|
Marcosm64 wrote: is it better to open the connection when the form loads and then close it when the application closes?
No, it isn't you should keep your connection open as short as possible but if you know that you have to execute several commands in a short period of time then you shouldn't open and close every time you execute a command.
|
|
|
|
|
|
I have a couple of problems with toolstrip tool tips I'm hoping someone can shed some light on.
First of all is the most annoying, and this occurs when I have a maximized window with a status strip and some toolstrip contrls on the status strip that have tool tips. When the user hovers over one of these controls, the tool tip (which would normally show up beneath the cursor) appears directly UNDER the cursor (because presumably it doesn't want to show over the task bar), however for some reason this creates a ridiculous looping effect where the tooltip appearing results in the mouse no longer being "over" the toolstrip item which hides the tooltip, which causes the mouse to once again appear over the item, which shows the tooltip, etc. etc. etc. It's humorous to watch.
The second is more important as it would provide an enhanced user experience if I can solve it, and that is that I need access to a toolstrip item (specifically toolstripsplitbutton)'s ToolTip, or at the very least the ability to explicitly hide it or ideally refresh it because I have a pair of back/forward buttons that I change the ToolTipText of to reflect the target of the button. For some reason, the tool tip is not updated immediately to reflect this, if it happens to be already visible.
If anyone has any knowledge of how to get more control over a ToolStrip's ToolTips please tell me.
Logan
|
|
|
|
|
Hi All,
i want to get the folder path which the user has selected in the explorer....
urgent please................
If U Get Errors U Will Learn
If U Don't Get Errors U Have Learnt
|
|
|
|