Set Column Property for a column in a revision table - vb.net

I am trying to set column property for a column called "description". I tried using IRevisionTableAnnotation and TableAnnotation to identify the table and neither of them have a command that lets me set the column property.
IRevisionTableAnnotation does let me set a custom property through SetColumnCustomProperty, but i want to set the column property given by default and not use custom column properties.
Is there any way I can assign the column properties available by default?

setcolumntype2 attribute for TableAnnotation will let you set the default properties for the table (Parameter to be entered in integer).

Related

How to get the value of a control that's bound to a binding source in VB?

I have a Dialog which has a ComboBox (aComboBox, say) with the following properties set:
DataSource linked to a BindingSource which is linked to an SQL table
DisplayMember linked to a column in that table which is of type String
Here is a pic of how the properties are set:
I want the String value of the item selected in the combo box but I am getting System.Data.DataRowViewwhen I use this code at run time:
aComboBox.SelectedItem.ToString()
How do I get the String value?
Do not use aComboBox.SelectedItem.ToString()
Instead of that Use : aComboBox.SelectedValue()
I managed to fix this by setting the Value Member attribute as shown in the following image, I am then able to retrieve the String value by calling aComboBox.SelectedValue.ToString() :
Note: Before, I only had the Display Member attribute set.

change value of field dynamically (OpenERP)

lets say I have a char field under osv.osv_memory
I generate a dynamic form (in "dialog" window) via the fields_view_get method containing this field.
During the generation of the dynamic form, how do I set the value of this field so that when the form is displayed it will contain this value (the value itself depends on the type of processing).
default_get works but only on initialization.
I can change attributes of the field such as readonly, string etc...
But the value itself need to be able to change.
If your osv.osv_memory object is opening from osv.osv, then first create a record of osv_memory object and try to open this record in the wizard. you will not need the default_get function now to load the data to the wizard

Web Dynpro ALV conditionally editable cells

The problem is I want that some cell of checkbox column in my WD ALV will be editable some cell will be non editable depending on some property.
I make next steps to achieve the required result:
1) Add attribute READONLY type WDY-BOOLEAN to the corresponding node ( attribute CHECK type WDY-BOOLEAN has already added ) .
2) Then in my code I Check some conditions in row of my table and assign attribute READONLY value abap_true or abap_false.
3) Then I bind my node with table. Table is filled correctly, I checked in debugger.
4) Configure my alv:
DATA: lo_table_settings TYPE REF TO if_salv_wd_table_settings,
lo_column_settings TYPE REF TO if_salv_wd_column_settings,
lo_column TYPE REF TO cl_salv_wd_column.
lo_column_settings ?= lv_value.
lo_table_settings ?= lv_value.
lo_column = lv_value->if_salv_wd_column_settings~get_column( 'CHECK' ).
DATA lr_checkbox TYPE REF TO cl_salv_wd_uie_checkbox.
" create checkbox
CREATE OBJECT lr_checkbox
EXPORTING checked_fieldname = 'CHECK'.
" make our table is editable
lo_table_settings->set_read_only( abap_false ).
lo_column = lo_column_settings->get_column( 'CHECK' ).
" Creating UI Elmenent 'INPUT FIELD' to make the column editable
DATA: lr_input_field TYPE REF TO cl_salv_wd_uie_input_field.
CREATE OBJECT lr_input_field EXPORTING value_fieldname = 'CHECK'.
lr_checkbox->set_read_only_fieldname( value = 'READONLY' ).
lv_value->if_salv_wd_column_settings~delete_column( ID = 'READONLY' ).
But it doesn't work, all of cells of checkbox column is editable and I don't get non editable cells of checkbox column.
To make a field A editable or readonly, it's only a matter of "using a field B's value to the A's readonly property".
So, as I understand , you have a column which is checkbox, and you want some rows to be editable ,and others to be readonly.
To do so, you won't need to create input field, the only thing you need to do is get the checkbox column reference and set its readonly property bind to the field in your data structure.
if that still doesn't work, check your data, whether the readonly field's value of each record is '', if yes, then of course, every cell of the check will be editable.
Your first step is correct. You added attribute READONLY of type WDY-BOOLEAN to your node and assigned it abap_true value before calling the grid.
The next step is to create input field reference for each field/row which you wanna make editable and assign this reference to the field attribute READONLY and change this attribute only for the lines that fit the condition.
Here is the sample code:
Initial assignment
loop at lt_table assigning field-symbol(<fs_table>).
<fs_table>-read_only = abap_true. " non editable
endloop.
Setting column editibility
* input type reference
data lr_input type ref to cl_salv_wd_uie_input_field.
* Retrieving all column id and reference
call method lv_value->if_salv_wd_column_settings~get_columns
receiving
value = data(lt_columns).
loop at lt_columns into ls_columns.
* Assigning column reference
data(lr_column) = ls_columns-r_column.
* Creating input field UI Element
create object lr_input
exporting
value_fieldname = ls_columns-id.
*Assigning input field to column to make it as editable
call method lr_column->set_cell_editor
exporting
value = lr_input.
* binding input field ref to READONLY field
lr_input->set_read_only_fieldname( value = "READONLY" ).
endloop.
Making single lines editable based on condition
loop at lt_table assigning field-symbol(<fs_table>).
if smth = abap_true
<fs_table>-read_only = abap_false. " non editable
endif.
endloop.
Check this guide for reference.

Changing Column header name of ListView using vb.net code

I have a listview with several columns. I want to change the column header using code.
Please advise how to do it.
I just tested ListView1.Columns(0).Text = "changed" and it worked. This is VB.Net, winforms, VS 2010.
To change the header name, you have to use the name property
Listview1.columns(0).name = "column1Name"
But you can also assign the column name while assigning it's "text" value
Listview1.Columns.add("Column1text").name = "Column1Name"
You can then use it's name to refer to it
Listview1.columns.item(Listview1.columns("Column1Name").index).text = "Column1TextChanged"
In a List View, there is a difference between
Column Header .Name and Column Header .Text.
The .Text is displayed at the top of the List View.
The .Name is the Column Name which you can refer to in your code.
If you try to get the ListView1.Columns(0).Name in your code, it will always be "".
Unless, during the design time, in the edit column header properties,
you set Under Data, Application Settings, and Properties Binding,
the DisplayIndex Name Default Value is the .Name value.
ColumnHeader Properties

Show yes/no in bool column of gridview bound to datasource in Winforms?

I have a gridview that is bound to a datasource (Windows Forms, VB.NET). One of columns is a property of type boolean, and I want to show "yes/no" in the column instead of 0/1 or "true/false". Is this possible? Can you edit displays of columns that are bound?
I have encountered the same problem, unfortunately I didn't find an elegant solution.
Three workarounds are proposed:
Add another property to the data source's class, which returns your string representation of the boolean property. Hide the column showing the boolean value, display the column showing the string value.
Add an unbound string column, populate that column with the appropriate value for each row, and hide the boolean bound column.
Create a wrapper class for your data class, which exposes the properties as you'd like them to be shown in the datagrid.