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


ADVERTISEMENT

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 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++ :: Create File With Given Size And Then Randomly Access File To Populate It

Feb 17, 2015

I am interested in creating a file of a given size and then randomly accessing the file to populate it. Is there a way to quickly create, for instance, a 4 GByte file in C++, initially populated with garbage?

View 4 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 Sharp :: Listbox Item Display - How To Add Column From File To Combobox

Oct 4, 2012

How to display the item in listbox,which are selected from three combobox.

View 1 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++ :: 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# :: 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# :: 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

Visual C++ :: Get Streamreader To Read And Calculations To Populate Textbox

Jul 27, 2013

Here what i have so far, the error in the stream

[CODE]

Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim fileName As String = IO.File.ReadAllText("Grades.txt")
Dim GPA As Double = 0

[Code]....

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# :: WPF Binding List To ComboBox

Sep 30, 2014

trying to bind a List of Objects to a ComboBox (just for testing) but I can't seem to get it working :S

This is how my Object is setup:

public class User
{
public string ID { get; set; }

[Code].....

View 10 Replies View Related

C# :: Link Combobox With SQL Column

Oct 19, 2014

When I try to link combobox with sql column i get error !!

void comfunction() {
string constring = "Data Source=LC-VAIO\SQLEXPRESS;Initial Catalog=sample1;Integrated Security=True";
string query = "select * from tbltest";
SqlConnection cn = new SqlConnection(constring);
SqlCommand cmd = new SqlCommand(query,cn);
SqlDataReader dreader;

[Code] ....

I got error from "string sname = dreader.GetString("name"); "

And this how i try to link it...

View 9 Replies View Related

C# :: Adding Value To ComboBox After Button Is Pressed

Mar 10, 2014

I have been learning C# so I've been dragging and dropping. I have a "First Name" and "Last Name" text field. I want to add this to a combo box called something like "User List", which will list the last named then the first names. However I figure I can work with something that can get me to store the names in the combo box.

So. I have two things I need to know:

What do I have to do to have when the button is pressed, add to the combo box?

Is there a way to retain all the entries I have entered? Or no?

View 8 Replies View Related

C# :: Find Event For Combobox When Its Selected Value Changes

Jan 28, 2015

I'm trying to find an event for the combobox when its selected value changes , but I can't seem to find the right one since I've tried several events in the dataGridView that are just triggering at the wrong moments. I need to remove the selected item from that combobox so that it doesn't get selected again at the second combobox which usually have the same items .

View 5 Replies View Related

C# :: Select Next Item In Combobox Dropdown?

Mar 14, 2014

I'm having issues with selecting the next item in sequence in a combobox dropdown. The dropdown consists of letters A-Z and there is a timer that I have running to change the letter every x minutes. What I need to do is if, for example, letter A is selected, when the timer goes off, it will change to letter B, etc. If it's at letter Z, it needs to go back to the first item, letter A.

letterCode.SelectedIndex = letterCode.SelectedIndex + 1;
if (letterCode.SelectedIndex >= 26)
{
letterCode.SelectedIndex += 0;
}

I have the above, but I keep getting an error:

InvalidArgument=Value of '26' is not valid for 'SelectedIndex'.

how to get this working (letter changing logic block).

View 8 Replies View Related

C# :: Get Selection From ComboBox / Getting Binding Path Instead?

Nov 19, 2014

I have a comboBox that I created in XAML using using binding and I'm unable to get the selection. I've tried everything I could think of or find on, but no luck.

Here's the relevant XAML and C# code for the comboBox:

<ComboBox Name="projSelected" Selectionchanged="projSelected_Selectionchanged" HorizontalAlignment="Left" Margin="424,27,0,0" VerticalAlignment="Top" Width="199" DisplayMemberPath="proj"/>
projSelected.ItemsSource = DAL.projectList;

Then here is where I try to check the selected value:

private void projSelected_Selectionchanged(object sender, SelectionchangedEventArgs e) {
projectDataList.ItemsSource = null;
projectDataList.Items.Clear();

[Code] ....

And here is my output in the MessageBox that I'm using to test the code:

Quote

project=Website selected=employeeProjects.project

View 7 Replies View Related

C# :: Using Combobox To Change Image In Picturebox?

Jun 13, 2014

I've been working on making a sprite generator and this is one thing that has kept giving me difficulties. No matter what I've looked up nothing directly says how to nor can I find anything on a similar topic to try and apply to it either. I know how to add the resources and names for the options but how do I get the options to make my picturebox image change in relation to the selection?

View 4 Replies View Related

C/C++ :: How To Assign Lines Of Text Using Combobox

May 5, 2013

So I'm working on program I had in Windows Form Application.

I have a combobox that lists the years 1981-2013. Beside it, a simple Enter button.

I wanted to be able to assign individual lines of text to each year that would be displayed in the message box.

Like if the user selects 1981, clicks Enter and the message box displayed "In the year of 1981.." but if they select 1982, the message box displayed "In the year of 1982.." I have everything else I want working, except that I can't figure out how to assign different lines of text to different years.

View 2 Replies View Related

C Sharp :: Move Items In ComboBox?

May 17, 2012

I have a data-bound ComboBox and I populate a DataSet with the values returned from a SQL query.
 
        public DataSet CompanyArray(DataSet dataSet) {
            SqlConnection connection = InstancesTest.IDataInterface.DefineConnection();  
            SqlCommand command = new SqlCommand();
            command.CommandText = "usp_CompanyArray";
            command.CommandTimeout = 20000;

[code]....

All this works fine. The reason I populated it in an array was so that I could sort the items alphabetically. I know I could just do an "order by" in SQL but I chose this route.

What I'm after is putting a "Please Select" at index 0 in the ComboBox. How can I move this value to the top of the list, without reordering the sorted list?And I don't really want to insert a "Please Select" as a first row in a database table.

View 2 Replies View Related

Visual C++ :: How To Sort Combobox After It Has Been Created

Feb 1, 2013

I have a combobox which doesn't have the CBS_SORT style and after adding some items I'd like to offer the ability for the user to sort it alphabetically by clicking on a given button. How can I sort the combobx after it has been created and some items added to it ?

View 4 Replies View Related

Visual C++ :: Making Combobox Drop UP In MFC?

Nov 21, 2012

I'm using MFC, and I need to make the combo box drop down list to be draw up - above the contro, instead of below it. How to make this happen?

View 4 Replies View Related







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