Charles R Hankey
|
|
Group: Forum Members
Posts: 524,
Visits: 30K
|
This is both interesting and frustrating ( like so many things in our profession  ) In the example the only change i have made to Ivan's clever trick of placing the UG in a groupbox which handles the TabOrderController is to put that groupbox on a TabPage ( and are all the ultragrids in my app ) ctrl-Tab seems reserved to move between tab pages. But ctrl-E is also a problem. Not sure where the focus goes, since in watch window it shows e.keycode is not keys.E but CntrlKey {17} ( this is also true when it is Cntrl-TAB ) Oddly, Ctrl-A, Ctrl-X etc work as expected. And my code in the OnKeydown to have cntrl-Delete delete the row works fine, so I am not sure how the keycode is getting intercepted by the TabControl.. Notice in the sample that if the TabControl is removed, the groupbox/ultragrid work exactly as in the original example. I have not been able to figure out if this is a SF thing or just a .NET tabcontrol thing or where to intervene. If it is not fixable I need to convert my app to use panels or something instead but before I go that direction I'd like to know this can't be fixed and that I am not going to have the same problem there. Thanks in advance ( Ivan  )
|
|
|
Charles R Hankey
|
|
Group: Forum Members
Posts: 524,
Visits: 30K
|
Actually we got it working  It turns out my code to override the tabcontrol and to set focus coming out of the groupbox was the right thing. But your baseform code in ProcessCmdKey was what was actually making it leave the grid. That is the right place to put it ( though it still seems to have the problem of not knowing where to go next ) I took out your baseform code and it stopped working. Put it back in, took out my Ultragrid onkeydown code for the navigation and it still works. Oh, and I subclassed groupbox to call me.controls(0).focus() on Enter to be used where it just contains a grid. Created a property NextControl ( string ) and am trying to figure out how to say, in the Leave of the groupbox class "Set focus to the control named NextControl" Here's the latest
|
|
|
Greg McGuffey
|
|
Group: Forum Members
Posts: 2K,
Visits: 6.6K
|
Charles is like a kid in a candy store.....
|
|
|
Edhy Rijo
|
|
Group: StrataFrame Users
Posts: 2.4K,
Visits: 23K
|
Greg McGuffey (06/02/2010)
Charles is like a kid in a candy store.....  That is a common effect from SF
Edhy Rijo
|
|
|
Ivan George Borges
|
|
Group: StrataFrame MVPs
Posts: 1.9K,
Visits: 21K
|
By the way, since we are in this UltraGrid marathon, have you been dealing with date columns on the grids? I am going nuts trying to duplicate the DateTimePicker behavior where 1/1/1800 should show empty date and entering empty date should save 1/1/1800 to the table.
|
|
|
Charles R Hankey
|
|
Group: Forum Members
Posts: 524,
Visits: 30K
|
I only have one data field in my grid which defaults to now() so I didn't realize it was a problem until you mention it and I try to blank the date.
I just tried using an SF wrapper UltraDateTimePicker as an editor component and at least the error message is different. When I blank the field in the grid I get an error that i have violated the minimum on the datetimeconstraint and the date is set to 01/01/0001
I think modifying an editorcomponent is going to be the way to go, but haven't worked it out yet. Perhaps modifying the SF picker control to implement that interface Infragistics says is necessary to use a control in an Ultragrid ? Or just using a straight winforms datetime picker and implementing that interface as well as the logic that SF uses to blank dates on null?
|
|
|
Ivan George Borges
|
|
Group: StrataFrame MVPs
Posts: 1.9K,
Visits: 21K
|
Yep, guess we have this ahead of us.  The SF wrapper UltraDateTimePicker works just fine on itself, but when we set it to be the column editor, no luck.
|
|
|
Charles R Hankey
|
|
Group: Forum Members
Posts: 524,
Visits: 30K
|
I have not been able to figure out where to intervene to translate the null in the control to #1/1/1800# in the BBS.
There is a BeforeRowUpdate and AfterRowUpdate and I can test for e.row.cells("DateofSale").value and there is a .setvalue method but I don't see how to change the data coming from the BBS to a null if it is #1/1/1800# and to change it back on the update.
I don't have source, so I'm poking around in the dark. Have a question up on StackOverflow but didn't have any luck there on my last Ultragrid question. The tech support guy on the Infragistics forum really doesn't seem to have his heart in it and doesn't answer questions very well. A couple of people have asked questions like this and his answers have not been helpful.
Anybody know if DevExpress grid has this problem? I have their trial right now and considering switching over.
|
|
|
Ivan George Borges
|
|
Group: StrataFrame MVPs
Posts: 1.9K,
Visits: 21K
|
I was dealing with other things around here, back to the matter. I have also posted your question in the Experts Exchange forum and will get back to it now. The first to accomplish this gives a shout!
|
|
|
Charles R Hankey
|
|
Group: Forum Members
Posts: 524,
Visits: 30K
|
I seems the question we really need to ask is : How do we display the date #1/1/1800# as if it were null. And how do we save null to the datasource/bbs as #1/1/1800# The answers people seem to give seem to always start with telling you you can't have null dates in .NET ( which we know ) but they don't know about our framework's handling nulls as #1/1/1800#
|
|
|
Ivan George Borges
|
|
Group: StrataFrame MVPs
Posts: 1.9K,
Visits: 21K
|
Hi Charles. I think I found a way to handle this, not sure you will like it, but it seems to be working. The idea is to add an unbound column to you grid, you can do that with the grid designer clicking on the "Add Unbound Column" button at the Columns treeview item. Give it a Key name, like ubc_Date. Set its DataType to System.DateTime. We will use this unbound column to store your date from the table. Have a look at the code and let me know. #Region " Private Fields " '-- keep current cell state Dim _CellUpdating As Boolean = False #End Region #Region " Handled Events " Private Sub grdYourGrid_InitializeRow(ByVal sender As Object, _ ByVal e As Infragistics.Win.UltraWinGrid.InitializeRowEventArgs) _ Handles grdYourGrid.InitializeRow '-- check if there are rows to be initialized If Me.grdYourGrid.Rows.Count() = 0 Then Exit Sub End If '-- move record point to current row YourTableBO1.SeekToPrimaryKey(e.Row.Cells("yt_pk").Value) '-- if cell is updating, don't set unbound column If _CellUpdating = False Then '-- if underlying table has #1/1/1800#, show empty cell for date If YourTableBO1.yt_Date = #1/1/1800# Then e.Row.Cells("ubc_Date").Value = DBNull.Value Else e.Row.Cells("ubc_Date").Value = YourTableBO1.yt_Date End If End If '-- reset the flag _CellUpdating = False End Sub Private Sub grdYourGrid_AfterCellUpdate(ByVal sender As Object, _ ByVal e As Infragistics.Win.UltraWinGrid.CellEventArgs) _ Handles grdYourGrid.AfterCellUpdate '-- if unbound date column, deal with empty date If e.Cell.Column.Key = "ubc_Date" Then If e.Cell.Value Is DBNull.Value Then YourTableBO1.yt_Date = #1/1/1800# Else YourTableBO1.yt_Date = CDate(e.Cell.Value) End If End If '-- set the cell state to updating _CellUpdating = True End Sub #End Region
|
|
|
Ivan George Borges
|
|
Group: StrataFrame MVPs
Posts: 1.9K,
Visits: 21K
|
Ah, forgot to say... set the actual date column Hidden property to True.
|
|
|
Charles R Hankey
|
|
Group: Forum Members
Posts: 524,
Visits: 30K
|
YOU ARE MY HERO !  I will test this tonight and let you know
|
|
|
Charles R Hankey
|
|
Group: Forum Members
Posts: 524,
Visits: 30K
|
While I'm testing your solution, here's the response I got on StackOverflow. I'm thinking there might be a way to put an UltraDataSource between the BBS and the grid ?
Do you have an UltraDataSource backing your grid? If so, then e.Row.ListObject should be the UltraDataRow corresponding to the grid's row.
I often keep a reference to a business object in the UltraDataRow's Tag property, and I end up with InitializeRow methods that look like this (apologies for C# instead of VB.net):
private void mygrid_InitializeRow(object sender, InitializeRowEventArgs e)
{
try
{
UltraDataRow udr = e.Row.ListObject as UltraDataRow;
if (udr == null)
{
return;
}
MyRecord rec = udr.Tag as MyRecord;
if (rec == null)
{
return;
}
...
You can also access the underlying datasource values from udr.Band.Cells.
Hope this helps!
|
|
|
Charles R Hankey
|
|
Group: Forum Members
Posts: 524,
Visits: 30K
|
Você é um gênio e você é meu herói
|
|
|
Charles R Hankey
|
|
Group: Forum Members
Posts: 524,
Visits: 30K
|
Works beautifully ! ( though I was less successful in putting formatting for font, size and bold around the Portugese - some it got post before I could switch to English ) this will definitely solve my immediate issues and really isn't difficult to implement wherever I need dates in an Ultrawingrid Wow. I'm impressed
|
|
|
Ivan George Borges
|
|
Group: StrataFrame MVPs
Posts: 1.9K,
Visits: 21K
|
Charles R Hankey (06/09/2010)
Você é um gênio e você é meu herói Oh, that is perfect Portuguese!  Thank you for your kind words, Charles. Really glad it worked.
|
|
|
Ivan George Borges
|
|
Group: StrataFrame MVPs
Posts: 1.9K,
Visits: 21K
|
Charles R Hankey (06/09/2010) While I'm testing your solution, here's the response I got on StackOverflow. I'm thinking there might be a way to put an UltraDataSource between the BBS and the grid ?
Well, at least you got an answer over there, Experts Exchange didn't get me any.
|
|
|