Tema: Re: C#, ComboBox, DropDown
Autorius: none
Data: 2010-05-23 01:24:09
Čia offtopic, bet čia toks produkcijoje?
Messages.Error ("DataGridView (" + c.DataGridView.Name + ") combo column ("
+
c.Name + ") value type (" + c.ValueType.ToString () +
") does not match binded DataTable value type (" +
table.Columns[0].DataType.ToString () +
")!\r\n\r\nPlease contact support!");
"Jornada Del Muerto" <ask@me.email> wrote in message
news:ht0kji$okl$1@trimpas.omnitel.net...
> "zZz" <zZz@zirzilia.lt> wrote in message
> news:ht085a$1gv$1@trimpas.omnitel.net...
>> Turiu ComboBox'ą, kurio DataSource'as yra DataView (filtruoja reikšmes
>> ComboBox.DisplayMember like '%ComboBox.Text%').
>> Kaip padaryti, kad ComboBox'as po DropDown įvykio parinktų pirmą reikšmę
>> iš
>> sąrašo ir nepakeistų Text'o? :)
>>
>
> Sveiks,
>
> Jei gerai supratau problema tai, mano controlas toki metoda turi (tiesa
> by default pas mane visose select uzklausose grazinamas ID, NAME,...
> laikomasi kad pirmas laukas visada bus ID, antras pavadinimu - combo
> atveju jis visada vaizduojamas kaip tekstas combo):
>
> public class AlphaDataGridView : DataGridView, ISelectableDbItem
> {
> #region Methods
> /// <summary>
> ///
> /// </summary>
> /// <param name="index">Datagridview column index</param>
> /// <param name="table">Table</param>
> public void LoadColumnCombo (int index, DataTable table)
> {
> if (table != null &&
> index < Columns.Count)
> {
> if (Columns[index] is DataGridViewComboBoxColumn &&
> table.Columns.Count > 1)
> {
> DataGridViewComboBoxColumn c =
> (DataGridViewComboBoxColumn)Columns[index];
>
> // if we have datasource
> if (DataSource != null)
> {
> // Valid only for data binded DataGridViews which have DataTable
> assigned
> if (c.ValueType != table.Columns[0].DataType)
> {
> Messages.Error ("DataGridView (" + c.DataGridView.Name + ") combo
> column (" +
> c.Name + ") value type (" + c.ValueType.ToString () +
> ") does not match binded DataTable value type (" +
> table.Columns[0].DataType.ToString () +
> ")!\r\n\r\nPlease contact support!");
>
> // Do nothing then!
> return;
> }
> }
>
> c.DataSource = table;
> c.ValueMember = table.Columns[0].ColumnName;
> c.DisplayMember = table.Columns[1].ColumnName;
> }
> }
> }
>