Hi there,
I''m using a Grid Grouping Control which i have 3 columns.
My first and second column does not allow empty value.
And for the third column it allow null value.
I would like to validate the first and second column to make sure the user must key in some value
I''ve tried out for some functions but i couldn''t get what i want.
Hope that anyone of you would lend me a helping hand on this.
Thanks in advance...
ST
stanleyj
Syncfusion Team
January 18, 2006 04:15 PM UTC
Hi Wyejin,
You can either handle the TableControlCurrrentCellValidating / CurrentRecordContextChange events and checking the validation, you can cancel it. (e.Inner.Cancel = true / e.Cancel = true).
Regards,
Stanley
AD
Administrator
Syncfusion Team
January 19, 2006 02:17 AM UTC
Hi Stanley,
Thanks for replying...
I was wondering, can i get the validating cell''s value with the 2 events you mention on the previous post?
If yes, mind giving me the sample cause there is so much other function insde and i don''t know which one to use..
Thanks in advance :)
ST
stanleyj
Syncfusion Team
January 19, 2006 05:39 AM UTC
Hi Wyejin,
See if these code helps.
Best regards,
Stanley
// To make sure that user types in Col1 & Col2 before leaving the record/row
private void gridGroupingControl1_CurrentRecordContextChange(object sender, Syncfusion.Grouping.CurrentRecordContextChangeEventArgs e)
{
if(e.Action == CurrentRecordAction.EndEditCalled)
{
Record rec = e.Record as Record;
if(rec != null)
{
string col1 = Convert.ToString(rec.GetValue("Col1"));
string col2 = Convert.ToString(rec.GetValue("Col2"));
if(col1 == "" || col2 == "" )
{
e.Cancel = true;
}
}
}
}
// To make sure that user types in Col1 & Col2 before leaving the currentcell
private void gridGroupingControl1_TableControlCurrentCellValidating(object sender, GridTableControlCancelEventArgs e)
{
GridCurrentCell cc = e.TableControl.CurrentCell;
GridTableCellStyleInfo style = e.TableControl.Model[cc.RowIndex, cc.ColIndex];
if(style.TableCellIdentity.TableCellType == GridTableCellType.RecordFieldCell && ( style.TableCellIdentity.Column.Name == "Col1" || style.TableCellIdentity.Column.Name == "Col2"))
{
if(cc.Renderer.ControlText == "")
e.Inner.Cancel = true;
else
e.Inner.Cancel = false;
}
}
AD
Administrator
Syncfusion Team
January 19, 2006 09:32 AM UTC
Thanks again for replying me...
The codes that you provide me works perfectly, but unfortunately, there is still some problem..
i''ve attached a few screen shots and my codes to let you have a better picture of what i mean..
Thanks in advance...
Sync.zip
ST
stanleyj
Syncfusion Team
January 19, 2006 02:56 PM UTC
Hi Wyejin,
Refer this
sample, let me know if you can reproduce that behavior.
Best regards,
Stanley
AD
Administrator
Syncfusion Team
January 20, 2006 01:44 AM UTC
Hi Stanley,
The sample you provide me doesn''t really help much. Is there anyway i can force the gridgroupingcontrol to update and accept the changes i made?
Thanks in advance....
AD
Administrator
Syncfusion Team
January 20, 2006 06:45 AM UTC
Hi Wyejin,
Attached is a sample in which I have bound a grid grouping control and a grid data bound control to the same data source to show the changes that are being made in a cell and which are getting updated. You may also try to refresh the grid or use RefreshRange methods to see if it might happen due to some refresh problem.
Regards,
Calvin.
_39802.zip
AD
Administrator
Syncfusion Team
January 20, 2006 12:05 PM UTC
Thanks for replying Calvin..
I''ve tried all the solutions that is provided, but i still can''t manage to solve it....
In this new attached text file, i''ve include all the functions and setting for my gridgrouping control.
I hope this helps. :(
Form11.zip
ST
stanleyj
Syncfusion Team
January 20, 2006 12:36 PM UTC
Hi Wyejin,
Does cc.EndEdit() helps after cc.Renderer.ControlValue is assigned?
Best regards,
Stanley
AD
Administrator
Syncfusion Team
January 21, 2006 03:03 AM UTC
Hi...
i tried ....
this.dgColor.Table.CurrentRecord= null;
cc.Renderer.UpdateControlValue();
cc.Renderer.CurrentCell.EndEdit();
this.dgColor.Table.CurrentRecord.EndEdit();
cc.EndEdit();
this.dgColor.EndUpdate(true);
but non of them works...
AD
Administrator
Syncfusion Team
January 21, 2006 03:30 AM UTC
Hi i tried removing the TableControlCurrentCellValidating() event for my grid.. and the problem is still there... so i decided to include my grid''s setting here... :(
this.dgColor.BackColor = System.Drawing.SystemColors.Window;
this.dgColor.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.dgColor.Dock = System.Windows.Forms.DockStyle.Fill;
this.dgColor.Font = new System.Drawing.Font("Tahoma", 8.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.dgColor.Location = new System.Drawing.Point(0, 0);
this.dgColor.Name = "dgColor";
this.dgColor.Size = new System.Drawing.Size(594, 312);
this.dgColor.TabIndex = 0;
gridColumnDescriptor1.Appearance.AddNewRecordFieldCell.CellValueType = typeof(string);
gridColumnDescriptor1.Appearance.AddNewRecordFieldCell.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
gridColumnDescriptor1.Appearance.AddNewRecordFieldCell.Font.Facename = "Tahoma";
gridColumnDescriptor1.Appearance.AddNewRecordFieldCell.Font.Size = 8.5F;
gridColumnDescriptor1.Appearance.AddNewRecordFieldCell.MaxLength = 10;
gridColumnDescriptor1.Appearance.AddNewRecordFieldCell.ReadOnly = false;
gridColumnDescriptor1.Appearance.AnyRecordFieldCell.CellValueType = typeof(string);
gridColumnDescriptor1.Appearance.AnyRecordFieldCell.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
gridColumnDescriptor1.Appearance.AnyRecordFieldCell.Font.Facename = "Tahoma";
gridColumnDescriptor1.Appearance.AnyRecordFieldCell.Font.Size = 8.5F;
gridColumnDescriptor1.Appearance.AnyRecordFieldCell.MaxLength = 10;
gridColumnDescriptor1.Appearance.AnyRecordFieldCell.ReadOnly = true;
gridColumnDescriptor1.Appearance.AnyRecordFieldCell.Trimming = System.Drawing.StringTrimming.EllipsisCharacter;
gridColumnDescriptor1.HeaderText = "Color Code";
gridColumnDescriptor1.MappingName = "ColorCode";
gridColumnDescriptor1.Name = "colColorCode";
gridColumnDescriptor1.Width = 180;
gridColumnDescriptor2.Appearance.AddNewRecordFieldCell.CellType = "TextBox";
gridColumnDescriptor2.Appearance.AddNewRecordFieldCell.CellValueType = typeof(string);
gridColumnDescriptor2.Appearance.AddNewRecordFieldCell.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
gridColumnDescriptor2.Appearance.AddNewRecordFieldCell.CultureInfo = new System.Globalization.CultureInfo("");
gridColumnDescriptor2.Appearance.AddNewRecordFieldCell.MaxLength = 50;
gridColumnDescriptor2.Appearance.AddNewRecordFieldCell.Trimming = System.Drawing.StringTrimming.EllipsisCharacter;
gridColumnDescriptor2.Appearance.AnyRecordFieldCell.CellValueType = typeof(string);
gridColumnDescriptor2.Appearance.AnyRecordFieldCell.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
gridColumnDescriptor2.Appearance.AnyRecordFieldCell.MaxLength = 50;
gridColumnDescriptor2.Appearance.AnyRecordFieldCell.Trimming = System.Drawing.StringTrimming.EllipsisCharacter;
gridColumnDescriptor2.HeaderText = "Description";
gridColumnDescriptor2.MappingName = "Description";
gridColumnDescriptor2.Name = "colDescription";
gridColumnDescriptor2.Width = 391;
this.dgColor.TableDescriptor.Columns.AddRange(new Syncfusion.Windows.Forms.Grid.Grouping.GridColumnDescriptor[] {
gridColumnDescriptor1,
gridColumnDescriptor2});
this.dgColor.TabStop = false;
this.dgColor.TopLevelGroupOptions.IsExpandedInitialValue = true;
this.dgColor.TopLevelGroupOptions.ShowCaption = false;
this.dgColor.TopLevelGroupOptions.ShowCaptionPlusMinus = false;
this.dgColor.TopLevelGroupOptions.ShowColumnHeaders = true;
this.dgColor.VersionInfo = "3.301.0.0";
AD
Administrator
Syncfusion Team
January 21, 2006 04:42 AM UTC
Hi Stanley and Calvin...
I realized that it is my CurrentRecordContextChange even''t coding that is causing the problem...
The problem has been solve thank you very much for the support that you two provide me... :)