|
Hi Robert,
In the Edit form, if the user changes the text of the Primary Key column, then I want to give the user, the option of "save as" rather than just overwrite the value.
For e.g.
Say Customer Name is a primary key and user has come to edit Customer details. If the user keys in a new Customer name (and leaves all other details as is), it should be saved as a new entry.
Any clues on this using the technique you have demonstrated.
TIA
|
|
|
|
|
Just like add new row, could you please tell me how to delete rows? i have a Ins,Upd,Delete trigger on my table. I implemented delete row but everytime i try to add a row after deleting one, the trigger throws an error about column values being null???
Any ideas?
|
|
|
|
|
Hey,
I'm having trouble with this..
I can get it to popup the edit form but I made a messagebox to alert what it was passing as the position and it's passing -1.
Any clue how this could be? Keep in mind, I'm new to this and have only been developing VB.NET for 3 days.
Any help would be appreciated!
|
|
|
|
|
-1 Usually means that there is no row selected or that it cannot find the row in the dataset.
- Robert R Freeman
|
|
|
|
|
Well I'm double clicking the row header so I know a row is selected and it exists...
Any other ideas?
|
|
|
|
|
I did the whole thing following instructions. It works, byt actually I`m not able to continue to add update functionality.
On the Detail Form, when I change the value in any comboboxe, then I`m not able to move mouse cursor from there.
Any suggestion?
|
|
|
|
|
I haven't heard of that one.
Make sure there aren't any breakpoints or stops in the value changed handlers.
Otherwise, it's probably an Operating System, Visual Studio, or .Net Framework bug.
Only thing I can think of is Rebooting or reinstalling the above.
- Robert R Freeman
|
|
|
|
|
Fortunatelly I found a (workaround) solution. I just set [data source update mode] of [text] property to Never.
So ... for anyone figthting with the same problem
- Select combobox
- in properties windows find Data/DataBindings/Advanced
- In new window openet select [Text] property and set hist [Data Source Update Mode] to [Never]
.
|
|
|
|
|
Thanks for posting your workaround.
- Robert R Freeman
|
|
|
|
|
Hey,
Are you sure you followed ALL the instructions? I had the same problem, and when you wrote your workaround, I knew what I was doing wrong: I forgot to apply this:
"Set the DataBindings.Text property to None since we're now binding to the SelectedValue property" (right before step 4).
Csabi
|
|
|
|
|
Hi Robert,
I'm new to DataGridView and datasets and your article helped me a lot! But I still have one question: how can I add new data to the data set using Detail edit form?
Thanks!
Csabi
|
|
|
|
|
It's actually quite easy.
Add another sub new to Order without the position parameter.
Use the BindingSource.AddNew method.
'This instantiation method will be used to insert a new record. No position is supplied.
Public Sub New(ByVal nwDataSet As NorthwindDataSet)
' This call is required by the Windows Form Designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
' We will specify the DataSet from the DataGrid form here
Me.NorthwindDataSet = nwDataSet
Me.OrdersBindingSource.DataSource = Me.NorthwindDataSet
Me.CustomersBindingSource.DataSource = Me.NorthwindDataSet
Me.EmployeesBindingSource.DataSource = Me.NorthwindDataSet
Me.OrdersBindingSource.AddNew()
End Sub
Then add the button or link and handle the click on Orders .
Private Sub LinkAddRow_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkAddRow.LinkClicked
Dim editForm As New Order(Me.NorthwindDataSet)
editForm.Show()
End Sub
If you want to do some intialization in Order , then use the OrdersBindingSource.AddingNew event.
- Robert R Freeman
|
|
|
|
|
Hello Robert!
Great article! Pretty much what I need to do, except I don't need to edit anything, just display the info on my "Detail Page".
Private Sub grdMain_RowHeaderMouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles grdMain.RowHeaderMouseDoubleClick<br />
If Me.grdMain.SelectedRows.Count > 0 Then<br />
Dim DetailsForm As New frmDetails(Me.PhaRxTestDataSet, _<br />
Me.PhaRxTestDataSet.SelectMainActive.Rows.IndexOf _<br />
(CType(CType(Me.grdMain.SelectedRows(0).DataBoundItem, DataRowView).Row, PhaRxTestDataSet.SelectMainActiveRow)))<br />
frmDetails.Show()<br />
End If<br />
End Sub
This is what I have on my side. "SelectMainActive" is a tableadapter I created. I think I can treat it just like a table. I get this error message with the above code,
Error 1 Too many arguments to 'Public Sub New()'. C:\Documents and Settings\Rudy\My Documents\Visual Studio 2005\Projects\RxMgmt\RxMgmt\Main.vb 28 47 RxMgmt
Any ideas what I may be doing wrong?
Thanks!
Rudy
|
|
|
|
|
This error usually means you either put too many arguments in your instantiation of frmDetails(Arg1, Arg2, Arg3) or you forgot to put the parameters in your Sub New on frmDetails.
- Robert R Freeman
|
|
|
|
|
Thanks Robert!
I'll try that.
Rudy
|
|
|
|
|
Hi Robert!
I have one more question. Where does the order_ID get passed. If I double click on Order ID "7", how am I passing that so I see the details of that order id 7. Normally I would have a SP with @OrderID, but I don't see how you are doing that.
In my case, I'm just showing 4 or 5 colmns from one table, that say has 12. The in the details, I just want to show all 12. But I want to pass the order_id, so I show the right details of the order.
Thanks!
Rudy
|
|
|
|
|
Hi Robert!
I figured it out. Thanks for the great article!
Rudy
|
|
|
|
|
How would you link the orders form's grid to the northwind dataset if you were doing this in code? How would you set the binding source in code. I am doing the same thing but in code. I can set up the dataset and grids on one form but don't know how to pass to a details form.
smh1
|
|
|
|
|
The code is automatically generated by visual studio. If you need to do this manually, look in the designer.vb files for the two forms.
- Robert R Freeman
|
|
|
|
|
I never thought of that. Thanks. I will take a look and see if that solves my problems.
smh1
|
|
|
|
|
I know I am in the wrong place for this, But this code is just what I need for project I am working on. The only thing is that I am new to progrming (and so far I love it) and I am using C#. I have looked all over but cant find the same leason in C# can some one convert this to C#.
I got most of it to work I just cant get the code for the RowHeaderMouseDoubleClick .
Thanks
|
|
|
|
|
As a confident atheist:
Please abstain from religious announcements.
Do you want al-Qaida to use this community to spread it's assumptions, as well?
Anyway: Last year I also wrote a (C#) detail view, inspired by the PL/SQL Developer.
I used the mighty but undervalued PropertyGrid to display and edit the values.
Regards
Marcus
|
|
|
|
|
Thank you for your comments Marcus. You should post a PropertyGrid article to CodeProject.
I haven't seen many examples with the PropertyGrid control outside of a development environment.
Note that my personal observations are listed only in my personal profile and as such have nothing to do with the article, but are of great import to who I choose to be. The rest of this is also personal, so do not read on unless interested.
As a Christian and as an American, I hold the First Amendment very dear. This country was founded with faith in God and I will gladly share my faith in any public forum. Faith in God is of paramount importance and those who miss out on this are forever harmed. Since I believe this, it is my moral obligation to let others know what I have come to know. It is up to the reader to come to their own conclusions. Please also note that the first two items, the issue of meaning/purpose, would apply to anyone, including Atheists. Just ignore the last parts.
This issue of meaning is not usually discussed, but always has the greatest impact on a person's life. The reason Al-Qaida is able to gain a following, to the extreme of suicide bombers, is by providing a purpose to those who lack it. Note that the two main reasons they follow are 1: purpose for God and 2: purpose for family (who are taken care of after their death). If those people already had a purpose, then they would be less likely to blindly follow men who claim to know their purpose.
That said, how can we know what to believe?
The answer is to take stock of all the possibilities and seek the truth. Always keep your mind open to other possibilities and information. I have done so and choose to believe in Christ. You seem to have done so and choose to believe in the nonexistence of any God. That is our free will. In either case, having considered one more possibility just bolsters each of our beliefs.
Atheism is: FAITH that there is NO God. This differs from Agnosticism.
The issues I have with Atheism are as follows:
1. There is too much order and logical complexity in the universe to occur without intelligent design.
2. Atheism requires closing your mind to the possibility of a God. This goes against the logic of seeking truth.
3. The disadvantages outweigh the benefits.
Pros: Freedom from spiritual considerations and the ability to discount an absolute/divine morality.
Cons: Still susceptible to cultural morality although you may choose to embrace complete immorality, no spiritual benefit, no eternal benefit, no miracles (physical benefit), and no divine purpose.
- Robert R Freeman
|
|
|
|
|
Hi Robert,
I didn't think too much about it when I used the word "atheist".
Agnosticism would have been the more accurate characterisation.
Thanks for the hint.
Marcus
|
|
|
|
|
Hey,
now can you do the whole thing programtically without having to use VS's visual aides.
This would be a great first step to making the whole process dynamic from say the contents/schema of a Dataset.
thanks
martin
life is a bowl of cherries
go on take a byte
|
|
|
|