Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
405
Ultragrid column display time with frames
posted

Hi,

I have an ultrawingrid that is bound to a binding list of objects. I have a column that is bound to a datetime property which should allow users to enter durations in hours, mins, secs and frames. 

I am using the following code for an ultramaskededit-

Dim edRunTime As Infragistics.Win.UltraWinMaskedEdit.UltraMaskedEdit = New Infragistics.Win.UltraWinMaskedEdit.UltraMaskedEdit()
edRunTime.InputMask = "hh:mm:ss.##"
edRunTime.EditAs = UltraWinMaskedEdit.EditAsType.UseSpecifiedMask
edRunTime.PadChar = "0"
edRunTime.Enabled = True
edRunTime.DisplayMode = UltraWinMaskedEdit.MaskMode.IncludeLiteralsWithPadding
edRunTime.DataMode = UltraWinMaskedEdit.MaskMode.IncludeLiteralsWithPadding
edRunTime.ClipMode = UltraWinMaskedEdit.MaskMode.IncludeLiteralsWithPadding

And setting the mask to the column using the following code-

timeCodeIn.Format = "HH:mm:ss.ff"
timeCodeIn.Style = UltraWinGrid.ColumnStyle.Edit

timeCodeIn.EditorComponent = edRunTime
timeCodeIn.UseEditorMaskSettings = True

When I enter any value in the cell, eg: 00:00:10.20 and exit the cell, the cell's display changes to 00:00:10.00. When I click back into the cell and it goes into edit mode I can see the correct value.

The above code works fine when the column is of type string, but not when the column is of type datetime.

Any idea how i can get this to work for a date time column???

Parents
No Data
Reply
  • 6120
    Offline posted

    Hi Karthik, 

    Our Masked Editor has the ability to add mask in hh:mm:ss or hh:mm tt, where tt is the token for AM/PM, adding milliseconds token to Masked Editor input mask will be a new product idea. Alternatively you can use UltraTimeSpan Editor to set specific TimeSpan including milliseconds. It supports rendering values of type System.TimeSpan and I assume this is what you are looking for.  

     If you have to use UltraMaskedEditor only, then you can add milliseconds by using a DataFilter which allows you to save fractions of time and then display them back in the editor. You can extract the ## characters value using a DataFilter from your editor and save them to your cell value, by using EditorToOwner. Similarly, you can extract the milliseconds from the cell’s value, and set the text of the editor with the constructed value by using OwnerToEditor.  You can refer to the following link to read more about DataFilter.

    http://devcenter.infragistics.com/Support/KnowledgeBaseArticle.aspx?ArticleID=5014

    The initial framework for it is below:  


    private void Form1_Load(object sender, EventArgs e)
            {
                ultraGrid1.DataSource = BuildData(new int[] { 10 });
               
                uwg.UltraGridColumn colTime = this.ultraGrid1.DisplayLayout.Bands[0].Columns["datetime1"];

                UltraMaskedEdit edMask = new UltraMaskedEdit();
                edMask.InputMask = "hh:mm:ss.##";
                edMask.DataFilter = new MaskToTimeSpan();
            }

            public class MaskToTimeSpan : IEditorDataFilter
            {
                public object Convert(EditorDataFilterConvertArgs conversionArgs)
                {
                    DateTime dtIn = (DateTime)conversionArgs.Value;


                    string sMS = string.Empty;
                    switch (conversionArgs.Direction)
                    {
                        case ConversionDirection.DisplayToEditor:
                            break;
                        case ConversionDirection.EditorToDisplay:
                            break;
                        case ConversionDirection.OwnerToEditor:
                            break;
                        case ConversionDirection.EditorToOwner:
                            break;
                    }

                    return dtIn;
                }
            }

          

    Please let me know what approach you would like to take and I can help you with that. If you want to suggest this as product idea then, you can suggest new product ideas for future versions (or vote for existing ones) at <http://ideas.infragistics.com>. 

    Submitting your idea will allow you to communicate directly with our product management team, track the progress of your idea at any time, see how many votes it got, read comments from other developers in the community, and see if someone from the product team has additional questions for you. 

    Remember when submitting your idea to explain the context in which a feature would be used and why it is needed as well as anything that would prevent you from accomplishing this today. You can even add screenshots to build a stronger case. Remember that for your suggestion to be successful, you need other members of the community to vote for it.  You can also link back to this thread for additional details.

    Thank you in advance to submitting your product idea. 

    Sincerely,

    Sahaja Kokkalagadda

    Associate Software Developer, Windows Forms

    http://www.infragistics.com/

     

Children
No Data