comboBox -- saving valueMember but showing displayMember - combobox

Just starting to use VS2013. Have several projects that I am porting from older technology. This should be really simple, so I am sure I am missing something easy.
The combo box is used to build a record. There is an ID field and a Description field. Very simple. I am trying to show the Description (which is text), but save the ID (which is int).
DataSource = table1BindingSource
DisplayMember = Description
ValueMember = ID
Databinding.Text = table2BindingSource.field1
I have tried setting
Databinding.SelectedValue = ID
and
Databinding.SelectedItem = ID
It displays in the dropdown correctly. It displays in the field correctly, using the Description. But value must not be associated with the field correctly, because I cannot save or move to the next record. Looks like the Description is getting put in the field1, and as it is int, it is not accepting it.
What am I missing?

I got it. For text boxes, I had been assigning
DataBinding.Text = Table1.field
So, I was trying to assign for combo boxes
DataSource = Table1
DisplayMember = Table1.description
ValueMember - Table1.code
and
DataBinding.SelectedValue = Table1.code
DataBinding.Text = Table2.field
I finally removed the Text statement and assigned
DataBinding.SelectedValue = Table2.field
And it all worked as desired.

Related

viewcriteria is not working for data having word "and"

i am working with applying view criteria programaticlly, till now it was fine, but when i searched with "develop and unit test" it is showing 0 records even though my table having data. iam using like operator. could any one help on this .
i have one table, having option to filter by providing select combo box list of vales, for every column when i select any thing in lov in value change listener i am applying viewcriteria programatically on table vo.
note. every thing is programatic view object only there is no point of entity, or sql
Sample Code:
DCIteratorBinding bindIterator = ADFUtils.findIterator("Tri2EWS_ETKAPIData_VO1Iterator");//Table viewObject(programatic)
Tri2EWS_ETKAPIData_VOImpl voimpl = (Tri2EWS_ETKAPIData_VOImpl) bindIterator.getViewObject();
ViewCriteria viewCriteria = voimpl.createViewCriteria();
viewCriteria.setName("MyVc");
ViewCriteriaRow viewCriteriaRow = viewCriteria.createViewCriteriaRow();
viewCriteriaRow.setOperator("ViewAttr1", "LIKE");
viewCriteriaRow.setAttribute("ViewAttr1", "stack and OverFlow");
viewCriteria.add(viewCriteriaRow);
viewCriteria.setCriteriaMode(ViewCriteria.CRITERIA_MODE_CACHE);
voimpl.applyViewCriteria(viewCriteria, true);
voimpl.executeQuery();
voipmpl.getRowCount();//Getting 0 here (Actually i should get 1)
Turn on debug messages for ADF BC (jbo.debugoutput) so you can see the SQL that is being generated.
This will help you figure out if the query is correctly formatted.

How to add several rows for each item for a ListBox in winform

I have a collection with 50 objects.
Each object contains several things but we have at least
OrgNr, Register_Id, Name, MailDate, Subject
for each object.
Assume these have the following values
OrgNr = "2556745-8145"
Register_Id = "1001"
Name = "Thailaan Asian Market"
MailDate = "2016-05-23 13:01:20"
Subject = "LPP failure"
So when I read the first object and want to add the above five fields to the ListBox I want it to be displayed like this and as one column.
2556745-8145/1001
Thailaan Asian Market
2016-05-23 13:01:20
LPP failure
So all these five fields is like one item and should be clickable.
I have been looing everywhere but the only example I have found is this
http://www.codeproject.com/articles/2695/an-editable-multi-line-listbox-for-net.
I can't use this example because I want to be able to control when I want to add CR LF which is after each written field value
//Tony

Allow edits from different users appear in different color inside memo box : Microsoft Access 2010

I have a memo field which contains rich text. I am able to identify a user and change all the text in the box instead of just the text they added.
I am looking to write code which allows the text to be edited and after update , the edited text will appear a different color than the original text in the memo field.
I have tried :
Dim strNew As String
Dim strOld As String
If Me.txt_username_id = "grant" Then
strOld = Me.Form!txtnotesaboutproduct1.OldValue.ForeColor = vbBlack<br/>
strNew = Me.Form!txtnotesaboutproduct1.ForeColor = vbRed
End If
I have also tried
Dim ctlOld As TextBox<br/>
Set ctlOld = Me.Form!txtnotesaboutproduct1
If Me.txt_username_id = "grant" Then
ctlOld = Me.Form!txtnotesaboutproduct1.OldValue.ForeColor = vbRed
End If
Generally, I do this with a continuous subform for Notes, so that I can hold the data, date and user, rather than just one formatted text box. Though I do realize this might be a lot more real estate that you might have, you can use a conditional format within the subform. I do agree that if it is possible, you'll likely need to use HTML and not .Forecolor, which will change the entire box.

OxyPlot : ColumnSeries/BarSeries display value of each column

In my WPF app, I use OxyPlot. I bind my data to the PlotModel and all is working well.
I want to display the value of each column on the chart. Is it possible?
For reference, this example of BarSeries on site, I wish to show actual value of Apples of 2009, 2010 & 2011 respectively on each column. i.e. value of Value1 for the 2009Apples column, Value2 for 2010Apples and so on.
I looked up at the APIof the BarSeries (For WPF ColumnSeries used interchangeably).
Tutorials of Bar & other plots. But couldn't find such thing anywhere.
How do I achieve this?
Yes, just set the LabelFormatString property of your series.
var theSeries = new ColumnSeries();
theSeries.LabelFormatString = "{0:F2}"; // Example: 1.2311 will display like "1.23"
// Add your columns
theSeries.Items.Add(new ColumnItem(someValue);
// ...
There is also an optional property you can set called LabelPlacement. The default value is LabelPlacement.Outside:
theSeries.LabelPlacement = LabelPlacement.Middle;

Using HTMLDocument to manipulate HTML and show it in WebBrowser-control

I am trying to manipulate a requested document in the WPF WebBrowser-control. I already managed it to invoke JavaScript on loaded document, but I am not able to change the shown HTML-code in the control itself.
My (very simplified) code in the OnNavigating-Handler looks like this:
mshtml.HTMLDocument doc = (mshtml.HTMLDocument)View.browser.Document;
HTMLTableClass table = doc.getElementById("someTable") as HTMLTableClass;
if (table != null)
{
table.appendChild((IHTMLDOMNode)(doc.createElement("<tr>") as IHTMLElement));
}
doc.close();
The -element doesn't get appended to displayed document in the control.
Any hints are very appreciated!
I finally got it. Its only possible to change the content of the table by adding rows and cells which i wanted to avoid in first place. My approach was to directly change the content of the -tag, which didnt work.
mshtml.IHTMLTableRow row = table.IHTMLTable_insertRow(-1) as mshtml.IHTMLTableRow;
mshtml.IHTMLElement c = (mshtml.IHTMLElement)row.insertCell(0);
c.innerText = "some";
mshtml.IHTMLElement c1 = (mshtml.IHTMLElement)row.insertCell(1);
c1.innerText = "text";

Resources