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


ADVERTISEMENT

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# :: Datagridview Combobox Selection Clear After Adding New Row

Dec 25, 2014

I have 2 datagridview in one windows form, When I click row from datagridview1, it shows in datagridview2 (Select *from....). Also I have combobox column in datagridview2. My question is, when I select items in combobox, and click to new row in datagridview 1, datagridview2 combobox's is getting empty. it is my code:

private void dataGridView1_CellDoubleClick_1(object sender, DataGridViewCellEventArgs e) {
try {
int id = Convert.ToInt32
(dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["id"].Value);//3

[Code] .....

View 8 Replies View Related

C# :: Update DataGrid When User Makes Selection In ComboBox?

May 7, 2014

How can I update my dataGrid when a user makes a selection in the combobox?

Here's my ComboBox:

<ComboBox HorizontalAlignment="Left"
Margin="125,110,0,0"
VerticalAlignment="Top"

[Code]....

View 5 Replies View Related

C++ :: Selection Process Using Roulette Wheel Selection?

Feb 9, 2013

I'm trying to make a selection process using roulette wheel selection. To do this I created two matrix, one random probabilities and one increasing probabilities. The idea is to choose a number according to the random probabilities. Here is the code I've written.

#include <iostream>
#include <conio.h>
#include <cstdlib>
using namespace std;
int main (){
float select [5], prob [10], mat [5];
int c, r, z;
cout.precision (2);
cout << "Random Number:" << endl;

[Code]...

The result I got is as follows:

Random Number:

0.0013 0.56 0.19 0.81 0.59

Increasing Probabilities:

0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1

Selected Column:
0
5
6
8
9

The evaluation doesnt seem to start from c=0 again. The selected column should be 0, 5, 1, 8, 5.

View 6 Replies View Related

C# :: Binding A String To A Textbox?

Aug 5, 2014

I have a textbox with XAML

<TextBox Grid.Row="0" Grid.Column="1"
HorizontalAlignment="Stretch" VerticalAlignment="Center"
Text="{Binding Path = EventDate, Mode=TwoWay}" />

And the Property

[edit]Note that auto formatting has edited onpropertychanged to all lowercase[/edit]
/// <summary>
/// Date that the event took place
/// </summary>
public string EventDate {

[code]....

In the constructor I have

EventDate = "Enter Date";

I have added a button

<Button Grid.Column="3" Content="Add Record" VerticalAlignment="Center" Click="AddRecordButtonclick"/>
public void AddRecordButtonclick(object sender, RoutedEventArgs e) {
Debug.WriteLine("Date value: " + EventDate);
}

What I am finding when I run this code is that when the Add Record button is clicked, the output displays, "Date value: Enter Date" regardless of what text I have in the textbox bound to EventDate.

Is there something obvious which I am missing with binding of a string to a textbox?

I've added this to the xaml, but the property is still not updating in the debug line

<TextBox Grid.Row="0" Grid.Column="1"
HorizontalAlignment="Stretch" VerticalAlignment="Center"
Text="{Binding Path=EventDate, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />

View 7 Replies View Related

C# :: Data Binding Using Entity Frameworks

Dec 9, 2014

I've got a datagrid setup and i'm using an entity model as the datasource, i thought i had stuctured my query so that i would only get a single column result but the display within the datagrid shows two columns?

here's the xaml for the form

<Window x:Class="UpdateAccelaAssets.winUsersRemove"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Remove User" Height="300" Width="300">

[Code] .....

And I've attached a screenshot of the result.

Attached image(s)

View 3 Replies View Related

C++ :: Boost Binding - Comparing String Using Strcmp

Jun 5, 2014

I am trying to compare strings (char*) using strcmp but I am having a hard time doing it with boost::bind. It compiles but it crashes when I run it.

I have a std::vector<boost::shared_ptr<DeviceInfo>> cMonitoredDevices and one cCurrentDevices. I used a typedef DeviceContainer for std::vector<boost::shared_ptr<DeviceInfo>>.

DeviceInfo is a simply struct that contains a char[128] Name (and other fields not important for this issue) that I want to use to compare.

So I am trying to find the DeviceInfo (based on Name) that are in cMonitoredDevice but not in cCurrentDevices. My problem is retrieving the Name value for the strcmp. Here is what I have so far

for(DeviceContainer::iterator pDevice = m_cMonitoredDevices.begin();
pDevice != m_cMonitoredDevices.end(); pDevice++) {
if (std::find_if(cCurrentDevices.begin(), cCurrentDevices.end(),
boost::bind(&strcmp, boost::bind(&boost::shared_ptr<DeviceInfo>::value_type::Name, _1),
(*pDevice)->Name) == 0) == m_cMonitoredDevices.end()) {
}
}

View 2 Replies View Related

C++ :: Measuring Execution Time Of Static And Dynamic Binding

Jan 11, 2013

consider the code bellow

#include<iostream>
#include<ctime>
#include<boost/progress.hpp>
using namespace std;
class parent {
public:
virtual void dynamic_display(){

[Code] ....

I am getting the following as output

Calculating....Static Function is called1times
The number of processor clicks is0time is0
Calculating....Dynamic function is called1times
The number of processor clicks is0time is0
Static Function is called2times
Dynamic function is called2times
Static Function is called3times
Dynamic function is called3times

I am actually trying to calculate the time to execute a statically binding method and a dynamically binded one.consider only the first four lines in my output. Why am i not getting the actual result.

View 3 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# :: 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# :: 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

Visual C++ :: How To Adjust Combobox Height

Dec 30, 2013

how to adjust the combo box height?

I can adjust the combo box width and also the dropdown list height but not the combo box height.

View 12 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 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# :: Using ListView To Show Content (selected Item) In ComboBox?

Jan 25, 2015

I'm using listView to show content (selected item) in ComboBox, TextBox, Labels..

I was using

DropDownStyle = DropDown

and actually i use DropDownStyle = DropDownList.

With this change,

comboB.Text = Name;

stopped working correctly (onload), only work after first click any item. Why?

I tried too

private void comboB_KeyPress(object sender, KeyPressEventArgs e)
{
e.Handled = true;
}

but with copy/paste with mouse i can add text in ComboBox.

PS: My objective is combobox no editable.

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# :: Combobox And Button - Attempted To Read Or Write Protected Memory

Mar 30, 2014

I have two from in visual studio 2010 with C#. In form1 I have one combobox and one button .In form2 I have Reportviewer . When Button in form1 is clicked form2 is shown. Now my problem is when I click button to show form2 on the line Form2.Show(); this error appear : Attempted to read or write protected memory. This is often an indication that other memory is corrupt. What can i do? In form1 I have one combobox that combo fill with Database with this code in the Form Load:

private void DocReportOnlyAlalhesabSearch_Load(object sender, EventArgs e) {
//fill shahrestan Combo
if (Class.Global.CurrentYear.Length != 0) {
OleDbConnection conn1;
OleDbCommand cmd1;
cmd1 = new OleDbCommand();

[Code] ....

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







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