From: Simon Whale on
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)


From: Cor Ligthert[MVP] on
Simon,

Try to avoid Yes No dropdowns, it is mostly a lot of work (you need to
create a usercontrol), while everybody understands a checkbox which is easy
to do.

Cor

"Simon Whale" <simon(a)nospam.com> wrote in message
news:eIMSDWW1KHA.3412(a)TK2MSFTNGP05.phx.gbl...
> 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)
>
>
From: Simon Whale on
I can't avoid the yes no dropdowns as its a business requirement for an
insurance back office.


"Cor Ligthert[MVP]" <Notmyfirstname(a)planet.nl> wrote in message
news:%23PvB2eW1KHA.5972(a)TK2MSFTNGP06.phx.gbl...
> Simon,
>
> Try to avoid Yes No dropdowns, it is mostly a lot of work (you need to
> create a usercontrol), while everybody understands a checkbox which is
> easy to do.
>
> Cor
>
> "Simon Whale" <simon(a)nospam.com> wrote in message
> news:eIMSDWW1KHA.3412(a)TK2MSFTNGP05.phx.gbl...
>> 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)
>>
>>


From: Fred on


"Simon Whale" <simon(a)nospam.com> a �crit dans le message de groupe de
discussion : eIMSDWW1KHA.3412(a)TK2MSFTNGP05.phx.gbl...
> Hi all,

Hello,

> 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?

> With YesNo
> .DataPropertyName = "yesno"
> .HeaderText = "Question Answer"
> .DataSource = dt

It seems that you populate your combo with the same data as your
DataGridView (?)
Just fill your combo with Yes and No and don't bind its content.

--
Fred
foleide(a)free.fr