ComponentOne True DBGrid for .NET (2.0) Search HelpCentral 

C1DataColumn.ValueItems Property

Gets the ValueItems object for this column.

[Visual Basic]

Public Property ValueItems As ValueItems

[C#]

public ValueItems ValueItems {get;set;}

[Delphi]

public property ValueItems: ValueItems read get_ValueItems write set_ValueItems;

Example

The following code uses the ValueItems property to configure the Integer column as a tri-state checkbox:

·      Visual Basic

       Private Sub checkBox1_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles checkBox1.CheckedChanged

           Dim items As C1.Win.C1TrueDBGrid.ValueItems = Me.C1TrueDBGrid1.Columns("Integer").ValueItems

           If Me.checkBox1.Checked Then

               ' We're going to translate values - the DataSource needs to hold at least 3 states.

               items.Translate = True

               ' Each click will cycle thru the various checkbox states.

               items.CycleOnClick = True

               ' Display the cell as a checkbox.

               items.Presentation = C1.Win.C1TrueDBGrid.PresentationEnum.CheckBox

               ' Now associate the underlying db values with the checked state.

               items.Values.Clear()

               ' Unchecked.

               items.Values.Add(New C1.Win.C1TrueDBGrid.ValueItem("0", False))

               ' Checked.

               items.Values.Add(New C1.Win.C1TrueDBGrid.ValueItem("1", True))

               ' Indeterminate state.

               items.Values.Add(New C1.Win.C1TrueDBGrid.ValueItem("2", "INDETERMINATE"))

           Else

               items.Translate = False

               items.CycleOnClick = False

               items.Presentation = C1.Win.C1TrueDBGrid.PresentationEnum.Normal

           End If

       End Sub

·      C#

       private void checkBox1_CheckedChanged(object sender, System.EventArgs e)

       {

           C1.Win.C1TrueDBGrid.ValueItems items = this.c1TrueDBGrid1.Columns["Integer"].ValueItems;

           if( this.checkBox1.Checked )

           {

               // We're going to translate values - the DataSource needs to hold at least 3 states.

               items.Translate = true;

               // Each click will cycle thru the various checkbox states.

               items.CycleOnClick = true;

               // Display the cell as a checkbox.

                  items.Presentation = C1.Win.C1TrueDBGrid.PresentationEnum.CheckBox;

               // Now associate the underlying db values with the checked state.

               items.Values.Clear();

               // Unchecked.

               items.Values.Add(new C1.Win.C1TrueDBGrid.ValueItem("0", false));

               // Checked.

               items.Values.Add(new C1.Win.C1TrueDBGrid.ValueItem("1", true)); 

               // Indeterminate state.

               items.Values.Add(new C1.Win.C1TrueDBGrid.ValueItem("2","INDETERMINATE"));

           }

           else

           {

               items.Translate = false;

               items.CycleOnClick = false;

               items.Presentation = C1.Win.C1TrueDBGrid.PresentationEnum.Normal;

           }

       }

·      Delphi

       procedure checkBox1_CheckedChanged(sender: System.Object; e: System.EventArgs);

       var

      items: C1.Win.C1TrueDBGrid.ValueItems;

       begin

         items := Self.C1TrueDBGrid1.Columns['Integer'].ValueItems;

         if Self.checkBox1.Checked then

         begin

           // We're going to translate values - the DataSource needs to hold at least 3 states.

           items.Translate := True;

           // Each click will cycle thru the various checkbox states.

           items.CycleOnClick := True;

           // Display the cell as a checkbox.

           items.Presentation := C1.Win.C1TrueDBGrid.PresentationEnum.CheckBox;

           // Now associate the underlying db values with the checked state.

           items.Values.Clear;

           // Unchecked.

           items.Values.Add(C1.Win.C1TrueDBGrid.ValueItem.Create('0', False));

           // Checked.

           items.Values.Add(C1.Win.C1TrueDBGrid.ValueItem.Create('1', True));

           // Indeterminate state.

           items.Values.Add(C1.Win.C1TrueDBGrid.ValueItem.Create('2', 'INDETERMINATE'));

         end;

         else

         begin

           items.Translate := False;

           items.CycleOnClick := False;

           items.Presentation := C1.Win.C1TrueDBGrid.PresentationEnum.Normal;

         end;

       end;

For more information on this example, see the TriSateCheckBox sample located on http://helpcentral.componentone.com/ProductResources.aspx?View=Samples.

See Also

C1DataColumn Class | C1DataColumn Members | C1.Win.C1TrueDBGrid Namespace


Send comments about this topic to ComponentOne.
Copyright © ComponentOne LLC. All rights reserved.