Re: DataGridView with ComboBox column - Pre-select a value.

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Hi Robin,

Many thanks for the suggestion.

The SelectedIndex property for a ComboBox in a DataGridView column does
not exist.

Cheers,

Andy

RobinS wrote:
Set the SelectedIndex to the one you want displayed.

Robin S.

"Andy" <andy.and.suzanne.cooper@xxxxxxxxx> wrote in message
news:1163165414.892529.324170@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi,

I have a simple form with a DataGridView which contains a ComboBox
column. The ComboBox is successfully filled at run time from a
DataTable. The DataTable contains about 6 text values which are
displayed as a drop-down list

//Fill the combobox with the different methods of IP
connection.
this.colConnection_Method.DataSource =
DataTableIPConnectionMethods;
//Display the method names ...
this.colConnection_Method.DisplayMember =
"Method_Name";
// ... but store the selected method's primary key
value.
this.colConnection_Method.ValueMember = "Method_PK";

My question is how can I pre-select one of the ComboBox values?

I'm using VS 2005 C# on Windows XP.

Many thanks in advance,

Andy


.



Relevant Pages

  • Re: DataGridView with ComboBox column - Pre-select a value.
    ... RobinS wrote: ... The SelectedIndex property for a ComboBox in a DataGridView column does ... I have a simple form with a DataGridView which contains a ComboBox ...
    (microsoft.public.dotnet.framework.windowsforms.controls)
  • Re: DataGridView with ComboBox column - Pre-select a value.
    ... The same exception is raised when I try to set the associated ... RobinS wrote: ... I have a simple form with a DataGridView which contains a ComboBox ...
    (microsoft.public.dotnet.framework.windowsforms.controls)
  • Re: DataGridView with ComboBox column - Pre-select a value.
    ... Robin S. ... The SelectedIndex property for a ComboBox in a DataGridView column does ... I have a simple form with a DataGridView which contains a ComboBox ...
    (microsoft.public.dotnet.framework.windowsforms.controls)
  • Re: set selected index of a ComboBox
    ... The following example illustrates the usage of the FindString method and SelectedIndex property. ... The example is part of a runnable code sample in the ComboBox class overview. ... > But after that the ComboBox displays only the first entry of the list. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Cannot set SelectedIndex to -1 in ComboBox
    ... The value of the SelectedIndex property of the ComboBox control does ... BUG: ComboBox Does Not Clear When You Set SelectedIndex to -1 ...
    (microsoft.public.dotnet.languages.vb)