S
Simon Whale
Hi all,
[vb2008]
I need help with the following, I have a grid that i have put on there 2
textbox's and a combobox column which works ok.
When i then add the data by using the following code below, it works, my
problem is with the combobox "YesNo" it put the complete contents of the
datatable into the combobox for each row. My question is how can i limit
the drop down to 1 yes and 1 no. But at the same time display the correct
value according to the datatable?
Many Thanks
Simon
DataGridView1.Columns(0).Visible = False
DataGridView1.Columns(1).Visible = False
DataGridView1.Columns(2).Visible = False
DataGridView1.Columns(3).Visible = False
DataGridView1.Columns(4).Visible = False
'the questionno
Dim QNo As New DataGridViewTextBoxColumn
QNo.HeaderText = "Question No."
QNo.DataPropertyName = "SortNo"
Me.DataGridView1.Columns.Add(QNo)
'the question textbox in the grid
Dim xy As New DataGridViewTextBoxColumn
xy.HeaderText = "Question"
xy.DataPropertyName = "shortDescription"
Me.DataGridView1.Columns.Add(xy)
'drop down list on grid
'Dim xx As New DataGridViewComboBoxColumn
'xx.DataPropertyName = "defaultanswerYN"
'xx.Name = "YesNo"
'xx.Items.Add("Yes")
'xx.Items.Add("No")
'Me.DataGridView1.Columns.Add(xx)
Dim YesNo As New DataGridViewComboBoxColumn
With YesNo
..DataPropertyName = "yesno"
..HeaderText = "Question Answer"
..DataSource = dt
..ValueMember = "yesno"
..DisplayMember = "yesNo"
End With
DataGridView1.Columns.Add(YesNo)
'the Answer Question
Dim yx As New DataGridViewTextBoxColumn
yx.HeaderText = "Answer"
yx.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells
yx.DataPropertyName = "SOFTemplateText"
Me.DataGridView1.Columns.Add(yx)
'the view button
' Add a button column.
Dim buttonColumn As New DataGridViewButtonColumn()
buttonColumn.HeaderText = "Requests"
buttonColumn.Text = "Requests"
buttonColumn.UseColumnTextForButtonValue = True
buttonColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells
buttonColumn.FlatStyle = FlatStyle.Standard
DataGridView1.Columns.Add(buttonColumn)
[vb2008]
I need help with the following, I have a grid that i have put on there 2
textbox's and a combobox column which works ok.
When i then add the data by using the following code below, it works, my
problem is with the combobox "YesNo" it put the complete contents of the
datatable into the combobox for each row. My question is how can i limit
the drop down to 1 yes and 1 no. But at the same time display the correct
value according to the datatable?
Many Thanks
Simon
DataGridView1.Columns(0).Visible = False
DataGridView1.Columns(1).Visible = False
DataGridView1.Columns(2).Visible = False
DataGridView1.Columns(3).Visible = False
DataGridView1.Columns(4).Visible = False
'the questionno
Dim QNo As New DataGridViewTextBoxColumn
QNo.HeaderText = "Question No."
QNo.DataPropertyName = "SortNo"
Me.DataGridView1.Columns.Add(QNo)
'the question textbox in the grid
Dim xy As New DataGridViewTextBoxColumn
xy.HeaderText = "Question"
xy.DataPropertyName = "shortDescription"
Me.DataGridView1.Columns.Add(xy)
'drop down list on grid
'Dim xx As New DataGridViewComboBoxColumn
'xx.DataPropertyName = "defaultanswerYN"
'xx.Name = "YesNo"
'xx.Items.Add("Yes")
'xx.Items.Add("No")
'Me.DataGridView1.Columns.Add(xx)
Dim YesNo As New DataGridViewComboBoxColumn
With YesNo
..DataPropertyName = "yesno"
..HeaderText = "Question Answer"
..DataSource = dt
..ValueMember = "yesno"
..DisplayMember = "yesNo"
End With
DataGridView1.Columns.Add(YesNo)
'the Answer Question
Dim yx As New DataGridViewTextBoxColumn
yx.HeaderText = "Answer"
yx.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells
yx.DataPropertyName = "SOFTemplateText"
Me.DataGridView1.Columns.Add(yx)
'the view button
' Add a button column.
Dim buttonColumn As New DataGridViewButtonColumn()
buttonColumn.HeaderText = "Requests"
buttonColumn.Text = "Requests"
buttonColumn.UseColumnTextForButtonValue = True
buttonColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells
buttonColumn.FlatStyle = FlatStyle.Standard
DataGridView1.Columns.Add(buttonColumn)