C# :: Unable To Populate ComboBox From Observable Collection (String)

Mar 15, 2015

I have a window in WPF which I want the user to use to enter the information for a COM Port.

The intent is to populate two ComboBoxs from a two different ObservableCollection<string> which I am having no luck with.

I don't think that it is a DataContext issue, as I am able to get something from the ComRateList when the window opens, but nothing from BaudRateList. Either way I have included the way that the window is opened and DataContexts assigned...

When the code runs, the COM Port list is updated when the window opens - However, it is not updated when the user reclicks the ComboBox which was my intended behavour.

All the adds for the BaudRateList do not populate the ComboBox for the baud rates on start up, nor when the code is running.

When I step through the code, I can see all of the BaudRateList items being added... The window is called by the main window's datasource like so...

OpenSerialCommunication OpenView = new OpenSerialCommunication();
OpenView.Show();

This opens fine.

The OpenSerialCommunication.xaml is as follows: (Note that any business names have been replaced with [snip])

<Window x:Class="[snip].SerialCommunication.OpenSerialCommunication"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:serial="clr-namespace:[snip].SerialCommunication"
Title="Open COM Port - [snip]" Height="300" Width="300">
<Grid>

[Code] ....

View 1 Replies


ADVERTISEMENT

C# :: WPF Collection Not Updating With Observable-collection?

Mar 19, 2014

I have a WPF project where I am using the entity framework. I have switched all my collection types to ObservableCollection and I am also using the PropertyChanged event. The only way my collections update is if I close the application then restart it. I got to the point where I just created a new application with 1 entity and 1 combobox to display a collection and I still can't get the collection to update. In my code below I am calling the AddCustomer method to add a customer name to the Customers ObservableCollection without success.

class ViewModel:INotifyPropertyChanged {
Model1Container context = new Model1Container();
public ViewModel() {
Customers = new ObservableCollection<Customer>();
UpDate();

[code]....

View 9 Replies View Related

C# :: Populate ComboBox From Txt File

Sep 12, 2014

I am trying to fill a combobox using the data from a txt file, with the new line as a split.

Currently it is throwing a System.ArgumentException in mscorlib.dll

try {
string[] lineOfContents = File.ReadAllLines(Properties.Resources.departments_list);
foreach (var line in lineOfContents) {
string[] tokens = line.Split('

[Code]...

My txt list is a resource in my project.

Accounts,
Power,
Commercial,
Procurement,
HumanResources,
Plant,
IT,
Reinstatement,
HealthSafety

why this is throwing the exception?

View 8 Replies View Related

C Sharp :: How To Populate A Combobox With One Field Of Database Table

Apr 17, 2012

I would like to fill a combobox with particular field for example if i have atable with fields such as CustID, CustName, CustAge.

I would like to only fill the combobox with the Name filed such that only the CustNames will be field in the combobox and am able to write an event handler for the selected index.

View 1 Replies View Related

C++ :: Convert Integer To String And Populate Array?

Sep 4, 2013

// prompts the user for a non-negative numbers (>= 0)
// reads in the a number and checks
// keeps re-prompting user if the input is invalid (negative)

[Code].....

How do I go about Populating the elements in the array created, I keep getting a compiler error on this vArr[i] = tmp_stream.str.at(i);

View 1 Replies View Related

C++ :: Input With String Statement - Output Result With HTML Tags To Populate Web Page

May 3, 2013

I'm working on a CGI application. I'm trying to test my input with a switch statement and output the result with html tags to populate a web page. From within the switch, I've coded as follows:

HTML Code:
switch(mFunc) {
case 0:
cout << "<p><b>YOU ENTERED THE FOLLOWING TO BE CALCULATED:</b></p>" "<h2>"<< number1 <<"+" << number2 << "</h2>" << endl;
break;
case 1:
cout << "You've entered" << number1 <<"-" << number2 << "to be evaluated" << endl;
break;

I know that I'll need to put this in an html body with a content type as such:

HTML Code:
cout << "Content-type: text/html
";
cout << "<html><body>
";

Am I able to do that directly inside of the switch statement?

View 11 Replies View Related

C Sharp :: How Selected Value In Combobox Return String

May 29, 2013

string st=combobox1.selectedvale.tostring();

combo box return 2 item ,

1:text
2:value

The value of combo not type of(int),the value type (string)

How value ofcombobox return data with type(string)?

View 2 Replies View Related

C# :: Unable To Implicit Convert Type Int To String Though Declared Variables As String

Mar 26, 2014

Ok, so I'm writing this code and when I build it keeps saying cannot implicitely convert type int to string even though I declared my variables as string. Why is it giving me this error?

private static string Repair()
{
string result="";
string beep;
string spin;
Console.WriteLine("Does your computer beep on startup?:(y,n)");

[Code]...

View 3 Replies View Related

C++ :: Unable To Reverse Even Words In A String

Nov 25, 2014

I'm trying to reverse every even word in a string (not all of it). But I keep getting an empty output.

For example:

The mouse was caught in peg.
The esmou was thgauc in gep.
Underlined words (even words)

#include<iostream>
#include<string>
using namespace std;
int main()
{
string text, result, temp;
int word_count(0);
cout << "Enter a sentence: ";

[Code]...

View 1 Replies View Related

C :: Unable To Create A Function To Convert Int To String

Nov 10, 2014

I'm VERY new in programming and I'm having trouble converting an integer to string. I need to create a function for a programme I'm working on for my school. My problem is that i am only allowed to use the libraries stdio.h, time.h and stdlib.h as well as printf, scanf, system, srand, time and rand. If I was allowed to use itoa or pointers it would be easier but i am not.

View 4 Replies View Related

C :: Unable To Display Element Of Char String?

Mar 2, 2013

Why I cannot do this to display each element of my char string? What is the proper way?

Code:

char str[SIZE];
int i;
for(i=0; i<SIZE; i++)
{
printf("%s", str[i]);
}

View 4 Replies View Related

C :: Unable To Retrieve String As Array Variable

Feb 11, 2014

I am trying to read a tab delimited file containing 8 columns and store each element of the column as an 1-dimensional array. Though the program prints the strings correctly as in the commented printf but it doesn't give me first_col[0] value and so on. My code is as follows:

Code:

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main() {
FILE *int_file1;
int BUF = 1024;

[Code]...

The inputfile test.txt has the following elements:

34932 13854 13854 2012-01-07
172098 49418 53269 2012-01-07
-
-
-

View 7 Replies View Related

C++ :: Unable To Compare A String With A Char Pointer

Jan 28, 2013

Ok, I'm having a few problems with strings, mostly string functions saying they're not able to compare a string with a char pointer.

int main()
{
int counter = 0;
int x, y, z;

[Code].....

My goal is to take in a command and store it in a string. Different commands have different amounts of information I need. One command is "new flight <flightnumber> <seats available>". First, I try to understand which command is being asked, using the first character to decide. Once I can assume which command is being attempted, I try to separate the string into smaller strings (words) using strtok. I then compare the words that should be constant (new and flight), to make sure the command is syntactically correct (which I use strcmp for). Then I'll go on to create a new flight, which is a class that takes in a char * and integer (which is why I need to convert a char * to integer).

View 2 Replies View Related

C :: What Does Collection Of Parameters As Argument Of A Function Mean

Aug 27, 2013

What does collection of parameters as argument of a function in C mean? Also any place I can refer to find those parameters?

Googling gives me Parameters and Arguments But not really sure whether that is what is needed.

View 6 Replies View Related

C# :: Foreach And Modifying Objects In Collection

May 8, 2014

I have a class that loads the contents of a XML file into their respective object types and stores those objects in a list. Each object has its own list of objects with properties the program will later modify.

The problem I am currently having is that after looping through the objects and modifying the necessary properties the modifications do not persist. This leads me to believe I am modifying a copy of the object rather than the object I think I am modifying. I am not sure why this is happening as I believe I should be modifying the object that is referenced in the collection.

What I have tried, I started using LINQ to get the object I am looking to modify. After a little more research I don't think this can work properly due to the LINQ query returning a new object(copy of the object). Currently I am using nested foreach loops which still are not behaving the way I expect as the properties I am setting are not making their way back to the original object.

The PopulateLogSheet() in the following class is where the problem loop is.

class ChillerCheckCollection {
public List<Chiller> chillers = new List<Chiller>();
public void LoadChillers(string filePath) {
var availableChillers = (from chiller in Xdocument.Load(filePath).Descendants("chiller")
select new Chiller

[Code] ....

And here are the other classes referenced in the above class.

class Chiller {
public IEnumerable<LogSheet> chillerLogSheet = new List<LogSheet>();
public int chillerID;

[Code] ....

View 2 Replies View Related

C# :: Get Collection Of Data From Database Through SQL Class?

Apr 26, 2015

In my WPF application i have a SQL class which i am trying to use to store all of my SQL queries so far this is working fine for when i want to return one piece of data like this:

public string GetEnquiry_ContactName(int EnquiryID) {
string ContactName = null;
//Try to do the following if not then show the error message.
try {
//Create the SQL Connection
SqlConnection cn = new SqlConnection(Models.M_GlobalVariables.GetConnection);

[Code] ....

But if i want to return a collection of data like this:

public ObservableCollection<CompanyNames> GetCompanyNames () {
public class CompanyNames {
public string CompanyName { get; set; }
public CompanyNames(string name) {
CompanyName = name;

[Code] ....

It does not work and i get 'Not all code paths return a value' and ''List_CompanyNames' is a 'property' but is used like a 'type''. But if i have it in my ViewModel like this:

//Code for the 'Company Names' dropdown box
public class CompanyNames {
public string CompanyName { get; set; }
public CompanyNames(string name) {
CompanyName = name;

[Code] ....

It works absolutely fine but the whole point of my SQL class is to have all my SQL code in that class instead of some of it in the ViewModel.

View 14 Replies View Related

C++ :: Floating Point Numbers - Grid Collection Of Data

May 14, 2014

I have a program which generates lots of data points in 2D (x and y co-ordinates). Perhaps 1,000,000+ of these points. These are floating point numbers. The values all fall within a specific range -R/2 and +R/2.

I want to impose an 'imaginary' grid. Such that I can collect the number of each of these points falling within a specific grid location. The actual 'grid' size is variable.

Should I try and collate this data from my C++ program and then post-process it in some other s/w like matlab?

View 3 Replies View Related

C :: Find Smallest / Largest And Average Values In A Collection Of N Numbers

May 30, 2014

I seem to have reached a dead end in a program I am attempting to write.The purpose of the program is find the smallest, largest, and average values in a collection of N numbers. It needs to get the value of N before scanning each value in the collection of N numbers.I'm having trouble creating comparisons for each set. I have a feeling because of the way I structured my program, I'm unable to make a proper comparison. Maybe my approach was wrong as soon as I got to the for statement to loop N sets and N numbers.Here is my code so far:

Code:

#include <stdio.h>
int main (void)
{
int num_sets, num_of_integers;
int count, count2, set, sum = 0;
int num, avg;
}

[code]....

/* Here is where I would continue to attempt to make a comparison between sets to determine smallest to largest */

return 0;

View 5 Replies View Related

Visual C++ :: Design Class Objects To Support Outlining Of Collection Of Items

Sep 9, 2013

I am struggling with how to efficiently design my class objects to support the outlining of a collection of items. The collection would be sorted but would also have the ability to indent and outdent individual items representing a Parent and Child relationship (see attached).

An item could indent up to 5 levels deep. A summary level would be considered a Parent while items below the summary level would be consider as children.

View 6 Replies View Related

C# :: Populate Datagrid In WPF

Apr 3, 2015

I am trying to get a datagrid working in my program with populating a simple set of data. Which i can then expand on and bring in data from a database.

But even this little simple test datagrid does not seems to be working.

XAML Code

<DataGrid Grid.Row="6" Grid.Column="0" Grid.ColumnSpan="2" Margin="10" Name="DataGrid_1" ItemsSource="{Binding DataGridData}"></DataGrid>
<Button Grid.Row="6" Grid.Column="2" Margin="10" FontSize="12" Command="{Binding Path=GetDataGridData_Command}">Get Data</Button>

[Code].....

View 3 Replies View Related

C# :: Populate Data In Datagrid?

Mar 29, 2014

im trying to populate a datagrid, i have a datbase class

public static List<Product> LoadProduct()
{
....................
}

i have a product class

gettor & settors
public Product(int id, string Name, double Price, int Quantity)
{
productId = id;
productName = Name;
productUnitPrice = Price;
productQuantity = Quantity;
}

ive added the HTML code to set up the datagrid, which i can see via design tab, but filling it up is harder.

i uderstand it needs a

protected System.Data.SqlClient.SqlDataAdapter sqlDataAdapter1;
sqlDataAdapter1.Fill();// where it require a dataset or datatable
DataGridProduct.DataBind();

as it requires a datatable i converted the list to a datatable when i run it it says null, im not sure where im going wrong, i noe the list works as i tried populating on a table.

public static DataTable ToDataTable<T>(List<T> items)
{
}

View 1 Replies View Related

C# :: Populate Labels With A List Or Array?

Jun 9, 2014

I have a WPF grid made out of labels with two rows, Apples and Oranges currently without any information. Let's say I want to populate the grid to look like the picture below.

I was wondering what's the best way to populate the labels with a list or array? I was thinking about using a list and passing values into the list

E.g.

List <string> ApplesList = new List<string>();
ApplesList.Add("Red");
ApplesList.Add("Delicious"):

List<string> OrangesList = new List<string>();
OrangesList.Add("Orange");

etc...

But I was wondering it make sense to use a list. Or should I just use an array or 2D array?

Sometimes I wonder when would be best to use a list, array, or 2D array.

View 8 Replies View Related

C# :: How To Populate HTML TextBoxes With SQL Results

Mar 9, 2015

I have an HTML5 form with a number of text boxes on it. I would like these textboxes populating with data retreived from an SQL database, using inline C#. I have a stored procedure that returns the data.

View 8 Replies View Related

C# :: Linq To XML - Populate List With Multiple Values?

Aug 26, 2014

I have an XML document, formatted as such:

<?xml version="1.0" encoding="UTF-8"?>
<Books>
<Bookmark Name="1984" Folder="C:UsersmillerDownloads1984 (George Orwell) - Audio Book" Time="00:43:58.4080000" Chapter="0" />
</Books>

Each Element named Bookmark has 4 attributes, Name, Folder, Time, and Chapter.

I'd like to be able to just put all of them in ONE type of container, without making multiple lists... Is there any way, using Linq to XML, to maybe add all of these values to a Tuple?

View 14 Replies View Related

C# :: Listbox File Populate Filtered With Regex

Sep 27, 2014

i found somewhere online this code that populate my listbox with file names. Now is it anyhow possible to filter those names before it gets populated by regex ?

Code:

private void PopulateListBox(ListBox lsb, string Folder, string FileType)
{
DirectoryInfo dinfo = new DirectoryInfo(Folder);
FileInfo[] Files = dinfo.GetFiles(FileType);
foreach (FileInfo file in Files)
{
lsb.Items.Add(file.Name);
}
}

Call on form load:

PopulateListBox(listBox1, Application.StartupPath, "*.exe");

Now is there way to add regex for filename?

View 5 Replies View Related

C# :: Populate Textboxes And ComboBoxes Through Data Grid View?

Dec 23, 2011

i m working on a simple project, i want to populate my text boxes and comboBoxes through DataGridView, means when i double click on cell content then the text boxes are populated.my question is that if i have to populate comboBox with the specific value then what i have to do then because comboBox.selectedItem is an object but my class property is a string..

e.g
combobox shows 30 days in it and my class is Code: class account
{
public string day{set;get}

[Code]....

but that does not happen because "comboBox.selectedItem" is an object so if i have to do that what i have to do then?

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved