I have some ComboBoxes in a UserForm. One of the ComboBoxes is a multicolumn ComboBox with three columns and is dependent on another ComboBoxs' value.
Does anyone know WHY when I choose one of the lines in the multicolumn combobox shows only the first column value?
I want the value from the second column to be visible when I choose a line.
The Combox Property that set which column to display in the TextBox portion of the Combobox is TextColumn
Property values:
-1 = Display the first column whose width (set by ColumnWidths property) is > 0
0 = Display the value of ListIndex
1 = Display column 1
etc
Related
I have several fields on a form that absolutely will not display a boolean value which is set to display as Yes/No, the dropdown menu is set to only offer Yes/No as options, but no matter what I do, the values displayed on the form always show True/False instead. Pictures below:
At this point I'm not entirely sure what it is that's causing this, but it's kind of annoying.
If you want to use a ComboBox, set the ComboBox properties as follows
In the data section:
Control Source = <name of your table or query column>
Row Source Type = Value List
Row Source = -1;Yes;0;No ' Alternating values and texts.
Bound Column = 1
Limit To List = Yes
In the format section
Column Count = 2 ' Because we have a value and a text.
Column Widths = 0cm ' This makes the first column invisible.
In my project , i have 2 windows forms and 1 gridview contains 5 columns (name gridv)
I want to fill 4 columns from forms1 and the 5th columun from the forms2
but i can't do it (error in my appli execution )
my code (how to fill the 5th column)
Dim selectrow As Integer = Form1.gridv.CurrentRow.Index ' selectrow mean selected row indice
MessageBox.Show("ligne selectionnée : " & Convert.ToDouble(selectrow))
Form1.gridv.Rows.Add(corp_mail.Text = Form1.gridv.Item(4, selectrow).Value) ' fill the 5th column`
You haven't shown the error but from what information you have given this is what your code is doing:
evaluates if corp_mail.Text is equal to the value of the 5th column of the selected row. This is a true or false, not a string.
Adds (or tries to) a new row to the grid with true or false as the value of the first cell.
If I understand correctly, this is what you want to do:
Form1.gridv.Item(4, selectrow).Value = corp_mail.Text
This will set the value of the 5th column of the selected row.
Although you mention a second grid on another form, not a textbox, so you probably have more work to do. But the idea is the same, instead of the TextBox value get the value from the other grid.
I have a combobox being databound from an sql stored procedure and I am trying to have the text change when I set the .SelectedValue to a different value but it does not change. Is there a way to make this behaviour occur?
the displayMember is set to Firstname and the ValueMember is set to an ID from a table and I am trying to change the text of the combobox programatically
cbo.SelectedValue = 3 will set the selected value but not alter the text appearing.
You can select in two ways, in example:
1) cbo.SelectedItem = "C" - for strings items
2) cbo.SelectedIndex = 3 - for strings and numbers.
Note: SelectedIndex first item has index=0.
I have a user form (excel, VBA) where there is a 2 column combobox. When user selects a certain value from the combobox, I want to get the value he selected, and the value associated with the first value (ie. the second column value).
How do I do this? Simply ComboBox1.Value returns the value of the first column. ComboBox1.Value(0) doesn't work.
Use the column property of the combobox. It is 0-based so the first column is column(0) and the second column is column(1).
Me.ComboBox1.Column(1)
Dim Comp = From C In db.Table1 _
Select C.Completed, C.Taken, C.Namne
Datagridview1.DataSource = Comp
Am using the Entity Framework and Columns Completed and Taken are of bit Datatype. When the query results are displayed in the datagridview, these bit columns are returned as of ColumnType Textbox - so i get a Datagridview textbox column with true or false string values.
I want to display Completed and Taken as Checkbox columns (either ticked for True or un-ticked for false) but ofcourse i can't do this in EditColumn dialogue because the Datagridview is unbound.
how can i change this in code at runtime
Edit:
I just looked at your code again and I realised that what you actually mean is that the DGV is bound rather than unbound? Since you're binding it to Comp.
If I understand correctly, just create 3 columns in the DGV at design time, 1 DataGridViewTextBoxColumn and 2 DataGridViewCheckBoxColumn. Then set the DataPropertyName of each column (Completed or Taken for the checkbox columns etc).
If the DataPropertyNames are correct the data will appear in them (if they're not correct, you'll end up with 6 columns in total).