SPREAD for ASP.NET 10.0J サンプルコード集 > セル型 > コンボボックス型セル > コードで項目を選択する |
CellクラスのValueプロパティに、コンボボックスの値を設定します。
ComboBoxCellType cbCell = new ComboBoxCellType() { Items = new string[] { "要素1", "要素2", "要素3" }, Values = new string[] { "1", "2", "3" }, UseValue = true, ShowButton = true }; FpSpread1.Cells[0, 1].CellType = cbCell; //コンボボックス型セルに値を設定します FpSpread1.Cells[0, 1].Value = 2;
Dim cbCell As New ComboBoxCellType() With { .Items = New String() {"要素1", "要素2", "要素3"}, .Values = New String() {"1", "2", "3"}, .UseValue = True .ShowButton = True } FpSpread1.Cells(0, 1).CellType = cbCell 'コンボボックス型セルに値を設定します FpSpread1.Cells(0, 1).Value = 2
クライアント側で処理することもできます。
ComboBoxCellType cbCell = new ComboBoxCellType() { Items = new string[] { "要素1", "要素2", "要素3" }, Values = new string[] { "1", "2", "3" }, UseValue = true, ShowButton = true }; FpSpread1.Cells[0, 1].CellType = cbCell;
Dim cbCell As New ComboBoxCellType() With { .Items = New String() {"要素1", "要素2", "要素3"}, .Values = New String() {"1", "2", "3"}, .UseValue = True .ShowButton = True } FpSpread1.Cells(0, 1).CellType = cbCell
<script type="text/javascript"> window.onload = function () { var spread = document.getElementById("FpSpread1"); spread.SetValue(0, 1, "2"); } </script>