Chat LIVE With Programming Experts! There Are 23 Online Right Now...

Welcome to Dream.In.Code
Become a C# Expert!

Join 244,305 C# Programmers for FREE! Get instant access to thousands of C# experts, tutorials, code snippets, and more! There are 790 people online right now. Registration is fast and FREE... Join Now!




C1flexgrid column cell validation as per the datatype

 
Reply to this topicStart new topic

C1flexgrid column cell validation as per the datatype

smithageo
18 Nov, 2008 - 01:04 AM
Post #1

New D.I.C Head
*

Joined: 17 Nov, 2008
Posts: 6

I want to validate C1flexgrid column cell as per the datatype assigned to it.


if it is int I want to set the max entry length to 10 ,if it is Decimal the want to restrict the entry like 2.000 etc.

Plz help...

User is offlineProfile CardPM
+Quote Post


n8wxs
RE: C1flexgrid Column Cell Validation As Per The Datatype
18 Nov, 2008 - 12:00 PM
Post #2

--... ...-- -.. . -. ---.. .-- -..- ...
Group Icon

Joined: 6 Jan, 2008
Posts: 1,609



Thanked: 223 times
My Contributions
Dream.In.Code has a policy by which we prefer to see a good faith effort on your part before providing source code for homework assignments. Please post the code you have written in an effort to resolve the problem, and our members would be happy to provide some guidance. Be sure to include a description of any errors you are encountering as well.

Please post like this:

Thank you for helping us helping you.
User is offlineProfile CardPM
+Quote Post

smithageo
RE: C1flexgrid Column Cell Validation As Per The Datatype
18 Nov, 2008 - 08:08 PM
Post #3

New D.I.C Head
*

Joined: 17 Nov, 2008
Posts: 6

CODE


public void Flex_ColumnValidation(int column,Type datatype )
        {
            if (cfg.Cols[column].DataType == datatype)
            {
                C1.Win.C1FlexGrid.CellStyle cs = cfg.Styles.Add("DateTime");
                cs.DataType = datatype;
                cs.Format = "dd-MMM-yyyy";
                //cs.Format = "dd-MMM-yy";
                //cs.Format = "dd-MM-yyyy";
                //cs.Format = "dd-MM-yy";
                //cs.Format = "MM-dd-yy";
                //cs.Format = "MM-dd-yyyy";
                //cs.Format = "MMM-dd-yyyy";
              
                cs = cfg.Styles.Add("Decimal");
                cs.DataType = datatype;
                cs.Format  =  "0,000.00";
                cs.EditMask = "0000.00";

                cs = cfg.Styles.Add("String");
                cs.DataType = datatype;
                cs.Format = "AAAAA";
                cs.EditMask = "AAAAAAAAAA";
                cs.Font = new Font(Font,FontStyle.Italic);

                C1.Win.C1FlexGrid.CellRange Crange;

                if (datatype ==typeof(DateTime))
                {  
                   // cfg.Cols[column].Style = cfg.Styles["DateTime"];
                    Crange = cfg.GetCellRange(1, column , 1, column);
                    Crange.Style = cfg.Styles["DateTime"];
                }
                else if (datatype == typeof(decimal))
                {
                  //cfg.Cols[column].Style = cfg.Styles["Decimal"];
                    Crange = cfg.GetCellRange(1, column);
                    Crange.Style = cfg.Styles["Decimal"];
                }
                else if (datatype == typeof(string))
                {
                   //cfg.Cols[column].Style = cfg.Styles["string"];
                   //cfg.Rows[1].Style = cfg.Styles["string"];
                    Crange = cfg.GetCellRange(1,column);
                    Crange.Style = cfg.Styles["string"];
                }
            }
            else
                MessageBox.Show("Invalid Datatype");
        }



Want to generalize the code and wish to get more options ....
User is offlineProfile CardPM
+Quote Post

smithageo
RE: C1flexgrid Column Cell Validation As Per The Datatype
18 Nov, 2008 - 10:57 PM
Post #4

New D.I.C Head
*

Joined: 17 Nov, 2008
Posts: 6

Modified the code again ...

CODE

public void Flex_ColumnValidation(int column,Type datatype )
        {
            if (cfg.Cols[column].DataType == datatype)
            {
                NumericUpDown editor = new NumericUpDown();
                editor.Increment = 1;
                editor.Maximum = 1000;
                editor.Minimum = 1;
                editor.ReadOnly = true;
                editor.BorderStyle = BorderStyle.None;

      C1.Win.C1Input.C1DateEdit dateedit = new Win.C1Input.C1DateEdit();
      dateedit.VisualStyle = C1.Win.C1Input.VisualStyle.Office2007Blue;
      dateedit.FormatType = C1.Win.C1Input.FormatTypeEnum.ShortDate;
              
                C1.Win.C1FlexGrid.CellRange Crange;

                C1.Win.C1FlexGrid.CellStyle cs = cfg.Styles.Add("DateTime");
                cs.DataType = datatype;
                cs.Format = "dd-MMM-yyyy";
              
                cs = cfg.Styles.Add("Decimal");
                cs.DataType = datatype;
                cs.Format  =  "0,000.00";
                cs.EditMask = "0000.00";

                cs = cfg.Styles.Add("String");
                cs.DataType = datatype;
                cs.Format = "LLLLL";
                cs.EditMask = "LLLLLLLLLL";
                cs.Font = new Font(Font,FontStyle.Italic);

                cs = cfg.Styles.Add("Integer");
                cs.DataType = datatype;
                cs.EditMask = "0000000000";
                cs.Editor = editor;

                cs = cfg.Styles.Add("Currency");
                cs.DataType = datatype;
                cs.Format = "c";
                cs.EditMask = "0000.00";
                cs.Font = new Font(Font, FontStyle.Bold);
                if (datatype ==typeof(DateTime))
                {                    
                    Crange = cfg.GetCellRange(1, column , 1, column);
                    Crange.Style = cfg.Styles["DateTime"];
                }
                else if (datatype == typeof(decimal))
                {
                    Crange = cfg.GetCellRange(1, column);
                    Crange.Style = cfg.Styles["Currency"];
                }
                else if (datatype == typeof(string))
                {
                    Crange = cfg.GetCellRange(1,column);
                    Crange.Style = cfg.Styles["string"];
                }
                else if (datatype == typeof(Int32))
                {
                    Crange = cfg.GetCellRange(1, column);
                    Crange.Style = cfg.Styles["Integer"];
                }
            }
            else
                MessageBox.Show("Invalid Datatype");
        }


want to use this method for validation in some projects.. Want to pass parameters as per the requirement. Any idea how to generalize it?

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 7/4/09 06:30PM

Live C# Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

C# Tutorials

Reference Sheets

C# Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month