Search Results

Search found 52 results on 3 pages for 'valuemember'.

Page 2/3 | < Previous Page | 1 2 3  | Next Page >

  • .NET 3.5 Listbox Selected Values (Winforms)

    - by Jimbo
    I am BATTLING to get the selected values (please note VALUES not TEXT) from a Winforms Listbox that has multi-select enabled and has been bound to a database table getting the Name (as DisplayMember) and ID (as ValueMember) - I need the ID of the selected items. The listbox control has properties for SelectedValue to get one of the selected items values, but not for all selected items values. The SelectedItems property returns a Listbox.SelectedObjectCollection from which I cannot seem to extract the VALUES of the items. Please help! Thanks.

    Read the article

  • Populate a combo box with one data tabel and save the choice in another.

    - by Scott Chamberlain
    I have two data tables in a data set for example lets say Servers: | Server | Ip | Users: | Username | Password | Server | and there is a foreign key on users that points to servers. How do I make a combo box that list all of the servers. Then how do I make the selected server in that combo box be saved in the data set in the Server column of the users table. EDIT -- I havent tested it yet but is this the right way? this.bsServers.DataMember = "Servers"; this.bsServers.DataSource = this.dataSet; this.bsUsers.DataMember = "FK_Users_Servers"; this.bsUsers.DataSource = this.bsServers; this.serverComboBox.DataBindings.Add(new System.Windows.Forms.Binding("SelectedValue", this.bsUsers, "Server", true)); this.serverComboBox.DataSource = this.bsServers; this.serverComboBox.DisplayMember = "Server"; this.serverComboBox.ValueMember = "Server";

    Read the article

  • C# Value member property repopulate or Re render the control..

    - by karthik
    Hi.. I just wanted to confirm couple of things. I) Code snippet: cmb1.Datasource= dt; cmb1.Valuemember = "value"; Does the control rendering happens 2 time for the control, 1 more time extra because of the value member getting changed after data source assigned. Is this so? II) How can I trace these re-populations in C#? I just wanted to debug and see and confirm? Example please? Thanks Karthik

    Read the article

  • DataBinding: ComboBox.Text not updating when SelectedValue changes?

    - by Rob
    This is the relevant designer code for the ComboBox: Me.ProbationComboBox.DataBindings.Add(New System.Windows.Forms.Binding("Enabled", Me.RegistrationBindingSource, "IsRegistered", True)) Me.ProbationComboBox.DataBindings.Add(New System.Windows.Forms.Binding("SelectedValue", Me.RegistrationBindingSource, "ProbationID", True)) Me.ProbationComboBox.DataSource = Me.ProbationBindingSource Me.ProbationComboBox.DisplayMember = "probation" Me.ProbationComboBox.ValueMember = "id" The problem is that when I call RegistrationBindingSource.ResetCurrentItem(), the SelectedValue property is refreshed with the correct value from RegistrationBindingSource.ProbationID(). However, the Text property is not updated. Until I can figure out the problem with my binding, I've been doing this as a fix: Me.ProbationComboBox.Text = CType(CType(Me.ProbationBindingSource.Current, DataRowView).Row, RootNamespace.DataSet.probationRow).probation Any ideas? Your assistance is appreciated!

    Read the article

  • ComboBox's Selected Value Changed On Lost Focus in VB.NET

    - by tunwn
    I have a datagridview(dgv) with a DataGridViewComboBoxColumn(colLocation) colLocation.AutoComplete = False colLocation.HeaderText = "Stored to" colLocation.DataSource = DB.getLocation() colLocation.DisplayMember = "description" colLocation.ValueMember = "id" I added the colLocation to dgv. "descirption" contains Unicode characters. I can see the comboBox correctly and choose the item. The problem is when the comboBox lost the focus, the value is changed to first item of the comboBox. Any suggestion? Updated: I found out that the ComboBox doesn't change the data when the DisplayMember is in English characters. It changes only when the DisplayMember is in Unicode chracter. Any idea for how could solve this? – tunwn 0 secs ago

    Read the article

  • how do i return arraylist from a function?

    - by KoolKabin
    Hi guys, I learnt example from msdn to populate a listbox control with arraylist. http://msdn.microsoft.com/en-us/library/1818w7we(v=VS.100).aspx I want to create a function which will give return the USStates arraylist and use the returned value as datasource for listbox1 Dim USStates As New ArrayList() USStates.Add(New USState("Alabama", "AL")) USStates.Add(New USState("Washington", "WA")) USStates.Add(New USState("West Virginia", "WV")) USStates.Add(New USState("Wisconsin", "WI")) USStates.Add(New USState("Wyoming", "WY")) ListBox1.DataSource = USStates ListBox1.DisplayMember = "LongName" ListBox1.ValueMember = "ShortName I tried creating a function like: Public Shared Function FillList() As ArrayList() Dim USStates As New ArrayList() USStates.Add(New USState("Alabama", "AL")) USStates.Add(New USState("Washington", "WA")) USStates.Add(New USState("West Virginia", "WV")) USStates.Add(New USState("Wisconsin", "WI")) USStates.Add(New USState("Wyoming", "WY")) return usstates end function but it says error: Value of type 'System.Collections.ArrayList' cannot be converted to '1-dimensional array of System.Collections.ArrayList'.

    Read the article

  • Winform BindingSources - Question

    - by Stephen Patten
    I have a windows form (net 2.0) with controls on it bound to an entity (w/ INotifyPropertyChanged) through a BindingSource..works. On the same form I have a drop down list that is also wired up through a BindingSource..works Here's a sample of the relevant code: m_PlanItemLookupBindingSource.DataSource = GetBusinessLogic().RetrievePaymentPlanLookups(); // Collection of PaymentPlans paymentPlanType.Properties.DataSource = m_PlanItemLookupBindingSource; paymentPlanType.Properties.DisplayMember = "Name"; paymentPlanType.Properties.ValueMember = "ID"; paymentPlanType.DataBindings.Add(new Binding("EditValue", m_PlanBindingSource, "PaymentPlanID", true, DataSourceUpdateMode.OnPropertyChanged, null, "D")); agencyComission.DataBindings.Add(new Binding("EditValue", m_PlanBindingSource, "AgencyCommission", true, DataSourceUpdateMode.OnPropertyChanged, null, "P1")); billingType.DataBindings.Add(new Binding("Text", m_PlanBindingSource, "BillingType")); So when I change a value in the drop down list I thought that the m_PlanItemLookupBindingSource Current property would change along with the PaymentPlanID property of the entity which does change. Just a bit confused. Thanks in advance, Stephen

    Read the article

  • C# Value member property repopulate the control..

    - by karthik
    Hi.. I just wanted to confirm couple of things. I) Code snippet: cmb1.Datasource= dt; cmb1.Valuemember = "value"; Here data population happens 2 time for the control, 1 More time extra,bcoz of value member getting changed after data source assigned. Is it true? II) How can I trace these re population in C#? I just wanted to debug and see and confirm? example please? Thanks Karthik

    Read the article

  • ToolStripComboBox.SelectedItem change does not propagate to binding source

    - by Marius
    My binding is set up as this: _selectXAxisUnitViewModelBindingSource = new BindingSource(); _selectXAxisUnitViewModelBindingSource.DataSource = typeof(SelectXAxisUnitViewModel); _selectedUnitComboBoxBindingSource = new BindingSource(); _selectedUnitComboBoxBindingSource.DataSource = _selectXAxisUnitViewModelBindingSource; _selectedUnitComboBoxBindingSource.DataMember = "AvailableUnits"; _selectedUnitComboBox.ComboBox.DataSource = _selectedUnitComboBoxBindingSource; _selectedUnitComboBox.ComboBox.DisplayMember = String.Empty; _selectedUnitComboBox.ComboBox.ValueMember = String.Empty; _selectedUnitComboBox.ComboBox.DataBindings.Add("SelectedItem", _selectXAxisUnitViewModelBindingSource, "SelectedUnit", true, DataSourceUpdateMode.OnPropertyChanged); // this is a bug in the .Net framework: http://connect.microsoft.com/VisualStudio/feedback/details/473777/toolstripcombobox-nested-on-toolstripdropdownbutton-not-getting-bindingcontext _selectedUnitComboBox.ComboBox.BindingContext = this.BindingContext; The property "AvailableUnits" is a collection of strings and the "SelectedUnit" is a string-property. Now the dropdown list is populated as expected, but when I select and item in the list, the change is not propagated to the binding source. Any idea what I am doing wrong?

    Read the article

  • Populate DataGridViewComboBoxColumn runtime

    - by ghiboz
    Hi all! I have this problem: I have a datagridview that reads the data from a db and I wish, for an integer column use a combobox to choose some values... I modified the column using DataGridViewComboBoxColumn type and after, on the init of the form this: DataTable dt = new DataTable("dtControlType"); dt.Columns.Add("f_Id"); dt.Columns.Add("f_Desc"); dt.Rows.Add(0, "none"); dt.Rows.Add(1, "value 1"); dt.Rows.Add(2, "value 2"); dt.Rows.Add(3, "value 3"); pControlType.DataSource = dt; pControlType.DataPropertyName = "pControlType"; pControlType.DisplayMember = "f_Desc"; pControlType.ValueMember = "f_Id"; but when the program starts (after this code) this message appears:

    Read the article

  • Comobox event SelectedValueChanged

    - by IordanTanev
    Hi, i have simple question may be someone asked it before me but i could not find it.Let say i have datatable that has some data from the database and i want to bind it to a combobox i use standart code like this comboBox1.BeginUpdate( ); comboBox1.ValueMember = "id"; comboBox1.DisplayMember = "name"; comboBox1.DataSource = dt; comboBox1.EndUpdate( ); The problem is during this binding the event SelectedValueChanged is fired.The problem is that rebind combo several times when outher values change and every time i must do sometihn like this comboBox1.SelectedIndexChanged -= new System.EventHandler( this.comboBox1_SelectedValueChanged ); my question is there a smarter way to skip the event when i comes from databinding not from user input.The problem is that i want to do it some how globaly in my control that inherits combobox and not to do it everytime in every from Best Regards, Iordand

    Read the article

  • Refresh combo box in Windows Form VB.NET

    - by fireBand
    Following is the code to populate combobox using DataSource Dim CountryList As Array = MyCtrl.GetAllCountries With cbCountyList .DataSource = CountryList .DisplayMember = "CountryName" .ValueMember = "CountryID" End With After adding a new COuntry Name to Database I want to reflect the changes in combobox. Repeating this code is not an option becasue it triggers SelectIndexChange event and had to do some crappy work around to avoid that. So I was wondering if there is way to refresh the combobox list. I actually thought binding with the DataSource property supposed to do it automatically. I also tried cbCountyList.Refresh() Thanks in advance.

    Read the article

  • Sort a DataGridView by DisplayMember

    - by Dave
    Hi, I have a DataGridView that is bound to a DataTable. In this table there are some foreign keys. I am then using the CellFormatting event to get the corresponding text from another database table for each foreign key. I want to sort the DataGridView when the user clicks the header. Automatic sorting works but is not correct as it is Sorting on the ValueMember (ForeignKey ID) and not on the DisplayMember (the text). I tried using the SortCompare event but then I read that it does not work on DataGridViews that use the DataSource property. How can this be done? Thanks

    Read the article

  • WinForms ComboBox DropDown and Autocomplete window both appear

    - by Clyde
    I've got a combobox on a winforms app with this code: comboBox1.AutoCompleteMode = AutoCompleteMode.SuggestAppend; comboBox1.AutoCompleteSource = AutoCompleteSource.ListItems; DataTable t = new DataTable(); t.Columns.Add("ID", typeof(int)); t.Columns.Add("Display", typeof(string)); for (int i = 1; i < 2000; i++) { t.Rows.Add(i, i.ToString("N0")); } comboBox1.DataSource = t; comboBox1.ValueMember = "ID"; comboBox1.DisplayMember = "Display"; I then follow these steps when the window opens: Click the combobox drop down button -- this displays the list of items and selects the text in the combobox Type '5', '1' ... i.e. I'm looking to use autocomplete to search for 515, 516, etc. You'll see that the autocomplete window now appears ON TOP of the drop down list. However if I mouse over, it's the obscured drop down window behind the autocomplete window that's receiving the mouse events, including the click. So I think I'm clicking on an autocomplete item but actually clicking on something totally random that I can't see. Is this a bug in the ComboBox? I'm using Windows 7 if that matters. Am I configuring the ComboBox wrong somehow? Note also that using the KEYBOARD uses the autocomplete drop down. So up/down arrow keys are using the front window, but the mouse is using the back window.

    Read the article

  • Bluetooth development on Windows mobile 6 C#

    - by cheesebunz
    Hi everyone, i recently started on a project which is a puzzle slider game. This application will be using the Bluetooth, and i'm working on the mobile,Samsung omnia i900. This is how my application will work. Any user with this Samsung device plays the game and starts sliding the tiles. There is an option to search and connect to other users with the same device and application, so that they can solve the puzzle together. Right now, i'm working on the Bluetooth Part but am still new to the API. I'm using the 32feet.NET inthehandpersonal.net class library while encountering much difficulties. I am able to search for devices by using: private void btnSearch_Click(object sender, EventArgs e) { BluetoothRadio.PrimaryRadio.Mode = RadioMode.Discoverable; BluetoothRadio myRadio = BluetoothRadio.PrimaryRadio; lblSearch.Text = "" + myRadio.LocalAddress.ToString(); bluetoothClient = new BluetoothClient(); Cursor.Current = Cursors.WaitCursor; BluetoothDeviceInfo[] bluetoothDeviceInfo = { }; bluetoothDeviceInfo = bluetoothClient.DiscoverDevices(10); comboBox1.DataSource = bluetoothDeviceInfo; comboBox1.DisplayMember = "DeviceName"; comboBox1.ValueMember = "DeviceAddress"; comboBox1.Focus(); Cursor.Current = Cursors.Default; } Well, to be honest this is a rip off from some sources i found on the internet but i do understand this part. Next i went on to trying to sending a simple "testing.txt" file and i'm stucked at it. I think i will be using something like the OBEX and Obexwebrequest, obexwebresponse, Uri etc. Could anyone explain it in simple terms for me so that i could understand what they are so that i could continue pairing and etc on Bluetooth development. Sorry making it this long, really appreciate if anyone did waste some time reading it :). Hope alanM sees this :) i'm using their bluetooth library.

    Read the article

  • OleDbExeption Was unhandled in VB.Net

    - by ritch
    Syntax error (missing operator) in query expression '((ProductID = ?) AND ((? = 1 AND Product Name IS NULL) OR (Product Name = ?)) AND ((? = 1 AND Price IS NULL) OR (Price = ?)) AND ((? = 1 AND Quantity IS NULL) OR (Quantity = ?)))'. I need some help sorting this error out in Visual Basics.Net 2008. I am trying to update records in a MS Access Database 2008. I have it being able to update one table but the other table is just not having it. Private Sub Admin_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Reads Users into the program from the text file (Located at Module.VB) ReadUsers() 'Connect To Access 2007 Database File con.ConnectionString = ("Provider=Microsoft.ACE.OLEDB.12.0;" & "Data Source=E:\Computing\Projects\Login\Login\bds.accdb;") con.Open() 'SQL connect 1 sql = "Select * From Clients" da = New OleDb.OleDbDataAdapter(sql, con) da.Fill(ds, "Clients") MaxRows = ds.Tables("Clients").Rows.Count intCounter = -1 'SQL connect 2 sql2 = "Select * From Products" da2 = New OleDb.OleDbDataAdapter(sql2, con) da2.Fill(ds, "Products") MaxRows2 = ds.Tables("Products").Rows.Count intCounter2 = -1 'Show Clients From Database in a ComboBox ComboBoxClients.DisplayMember = "ClientName" ComboBoxClients.ValueMember = "ClientID" ComboBoxClients.DataSource = ds.Tables("Clients") End Sub The button, the error appears on da2.update(ds, "Products") Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click Dim cb2 As New OleDb.OleDbCommandBuilder(da2) ds.Tables("Products").Rows(intCounter2).Item("Price") = ProductPriceBox.Text da2.Update(ds, "Products") 'Alerts the user that the Database has been updated MsgBox("Database Updated") End Sub However the code works on updating another table Private Sub UpdateButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UpdateButton.Click 'Allows users to update records in the Database Dim cb As New OleDb.OleDbCommandBuilder(da) 'Changes the database contents with the content in the text fields ds.Tables("Clients").Rows(intCounter).Item("ClientName") = ClientNameBox.Text ds.Tables("Clients").Rows(intCounter).Item("ClientID") = ClientIDBox.Text ds.Tables("Clients").Rows(intCounter).Item("ClientAddress") = ClientAddressBox.Text ds.Tables("Clients").Rows(intCounter).Item("ClientTelephoneNumber") = ClientNumberBox.Text 'Updates the table withing the Database da.Update(ds, "Clients") 'Alerts the user that the Database has been updated MsgBox("Database Updated") End Sub

    Read the article

  • Winforms, databinding, Listbox and textbox

    - by Snake
    Hi dear friends, I have a ListBox (MyListBox) on my screen, and a Textbox (MyTextBox). The ListBox is filled with a List(Of T), which are all custom items. Now I try to do this: The ListBox' datasource is the List(Of T). Now when an Item changes I want the textbox to be updated to a particular property of the selected item in my ListBox. In code this means: Me.MyListBox.DisplayMember = "SelectionName" Me.MyListBox.ValueMember = "Id" MyTextbox.DataBindings.Add(New Binding("Text", Me._listOfItems, "SelectedItem.Comment", True, DataSourceUpdateMode.OnPropertyChanged)) Me.MyListBox.DataSource = Me._listOfItems this does not work. But when I bind to SelectedValue instead of SelectedItem it works perfectly. The _listOfItems is declared as this: Dim _listOfItems As List(Of MyItem) = New List(Of MyItem)() Where MyItem is this: public class MyItem { public string SelectionName { get; set; } public int Id { get; set; } public string Comment { get; set; } } I tried overriding the ToString() in MyItem so that it would use that. But that doesn't work either. Anybody care to give it a try? Thanks! -Snakiej

    Read the article

  • Set the selected item for a combobox in a datagrid

    - by JingJingTao
    I am using a datagrid which has many combobox fields in it, when I click the datagrid combobox the selected item or highlighted value is the last item in the list, but I would like it to highlight the first(top) item in the list. I know for just a combobox, all I need to do is change the combobox.selecteditem or combobox.selectedindex, but I'm not sure what to do in this case. I have binded the combobox to a table in the database and used a datatable to store the combobox values and then I add a row to the datatable, I think the reason the last item in the combobox is highlighted is because I added a row to the datatable. Thank you for your help. String strGetTypes = "SELECT holidaycodeVARCHAR4Pk, codedescVARCHAR45 FROM holidaytype ORDER BY holidaycodeVARCHAR4Pk Desc"; DataTable dtHolidayType = new DataTable(); MySqlDataAdapter dbaElements = new MySqlDataAdapter(strGetTypes, ShareSqlSettings.dbConnect); dbaElements.Fill(dtHolidayType); DataGridViewComboBoxCell cboxDays = new DataGridViewComboBoxCell(); cboxDays.DataSource = dtHolidayType; cboxDays.DisplayMember = "codedescVARCHAR45"; cboxDays.ValueMember = "holidaycodeVARCHAR4Pk"; //Blank row dtHolidayType.Rows.Add(1); // gridDailyEmp.Rows[j].Cells[day] = cboxDays;

    Read the article

  • Strongly Typed Controls in .NET

    - by Tigraine
    I am working on a Windows Forms app for quite some time now, and I really find myself doing more typecasts in the GUI code than I ever did in my underlying business code. What I mean becomes apparent if you watch the ComboBox control that accepts some vague "object" as it's item. Then you go off and may display some DisplayMember and a ValueMember and so on. If I want to retrieve that value later I need to typecast my object back to what it was. Like with strings getting the value takes string value = (string)combobox1.SelectedItem; Since there are generics in the Framework for quite some time now, I still wonder why in the Hell not one control from the standard toolbox is generic. I also find myself using the .Tag property on ListViewItems all the time to keep the displayed domain object. But everytime I need to access that object I then need another typecast. Why cant I just create a ComboBox or ListView with items of type ListViewItem Am I missing something here or is this just another example of not perfectly well thought through controls?

    Read the article

  • How to maintain ComboBox.SelectedItem reference when DataSource is resorted?

    - by Dave
    This really seems like a bug to me, but perhaps some databinding gurus can enlighten me? (My WinForms databinding knowledge is quite limited.) I have a ComboBox bound to a sorted DataView. When the properties of the items in the DataView change such that items are resorted, the SelectedItem in my ComboBox does not keep in-sync. It seems to point to someplace completely random. Is this a bug, or am I missing something in my databinding? Here is a sample application that reproduces the problem. All you need is a Button and a ComboBox: public partial class Form1 : Form { private DataTable myData; public Form1() { this.InitializeComponent(); this.myData = new DataTable(); this.myData.Columns.Add("ID", typeof(int)); this.myData.Columns.Add("Name", typeof(string)); this.myData.Columns.Add("LastModified", typeof(DateTime)); this.myData.Rows.Add(1, "first", DateTime.Now.AddMinutes(-2)); this.myData.Rows.Add(2, "second", DateTime.Now.AddMinutes(-1)); this.myData.Rows.Add(3, "third", DateTime.Now); this.myData.DefaultView.Sort = "LastModified DESC"; this.comboBox1.DataSource = this.myData.DefaultView; this.comboBox1.ValueMember = "ID"; this.comboBox1.DisplayMember = "Name"; } private void saveStuffButton_Click(object sender, EventArgs e) { DataRowView preUpdateSelectedItem = (DataRowView)this.comboBox1.SelectedItem; // OUTPUT: SelectedIndex = 0; SelectedItem.Name = third Debug.WriteLine(string.Format("SelectedIndex = {0:N0}; SelectedItem.Name = {1}", this.comboBox1.SelectedIndex, preUpdateSelectedItem["Name"])); this.myData.Rows[0]["LastModified"] = DateTime.Now; DataRowView postUpdateSelectedItem = (DataRowView)this.comboBox1.SelectedItem; // OUTPUT: SelectedIndex = 2; SelectedItem.Name = second Debug.WriteLine(string.Format("SelectedIndex = {0:N0}; SelectedItem.Name = {1}", this.comboBox1.SelectedIndex, postUpdateSelectedItem["Name"])); // FAIL! Debug.Assert(object.ReferenceEquals(preUpdateSelectedItem, postUpdateSelectedItem)); } }

    Read the article

  • C# bluetooth file send.

    - by cheesebunz
    i'm new to bluetooth development and i found the 32netfeet . Right now i'm able to search for bluetooth devices nearby and connect to them but how do i send a file e.g SendTest.txt? I tried buttonclick event using the OBEX but i don't understand this is my example code: using InTheHand.Net; using InTheHand.Net.Sockets; using InTheHand.Net.Bluetooth; namespace BluetoothIntheHand { public partial class Form2 : Form { private Guid service = BluetoothService.DialupNetworking; private BluetoothClient bluetoothClient; public Form2() { InitializeComponent(); } private void btnSearch_Click(object sender, EventArgs e) { BluetoothRadio.PrimaryRadio.Mode = RadioMode.Discoverable; BluetoothRadio myRadio = BluetoothRadio.PrimaryRadio; lblSearch.Text = "" + myRadio.LocalAddress.ToString(); bluetoothClient = new BluetoothClient(); Cursor.Current = Cursors.WaitCursor; BluetoothDeviceInfo[] bluetoothDeviceInfo = { }; bluetoothDeviceInfo = bluetoothClient.DiscoverDevices(10); comboBox1.DataSource = bluetoothDeviceInfo; comboBox1.DisplayMember = "DeviceName"; comboBox1.ValueMember = "DeviceAddress"; comboBox1.Focus(); Cursor.Current = Cursors.Default; } private void btnConnect_Click(object sender, EventArgs e) { if (comboBox1.SelectedValue != null) { try { bluetoothClient.Connect(new BluetoothEndPoint((BluetoothAddress)comboBox1.SelectedValue, service)); MessageBox.Show("Connected"); } catch (Exception ex) { MessageBox.Show(ex.Message); } } } private void btnSend_Click(object sender, EventArgs e) { bluetoothClient.Connect(new BluetoothEndPoint((BluetoothAddress)comboBox1.SelectedValue, service)); String addr = "112233445566"; Uri uri = new Uri("obex://"+@"SendTest.txt"); ObexWebRequest req= new ObexWebRequest(uri); ObexWebResponse rsp; } I found the guide but don't really knw hw to convert to C# ' The host part of the URI is the device address, e.g. IrDAAddress.ToString(), ' and the file part is the OBEX object name. Dim addr As String = "112233445566" Dim uri As New Uri("obex://" & addr & "/HelloWorld2.txt") Dim req As New ObexWebRequest(uri) Using content As Stream = req.GetRequestStream() ' Using a StreamWriter to write text to the stream... Using wtr As New StreamWriter(content) wtr.WriteLine("Hello World GetRequestStream") wtr.WriteLine("Hello World GetRequestStream 2") wtr.Flush() ' Set the Length header value req.ContentLength = content.Length End Using ' In this case closing the StreamWriter also closed the Stream, but ... End Using Dim rsp As ObexWebResponse = CType(req.GetResponse(),ObexWebResponse) Console.WriteLine("Response Code: {0} (0x{0:X})", rsp.StatusCode)

    Read the article

  • Using Linq to filter a ComboBox.DataSource ?

    - by Pesche Helfer
    Hi board, in another topic, I've stumbled over this very elegant solution by Darin Dimitrov to filter the DataSource of one ComboBox with the selection of another ComboBox: how to filter combobox in combobox using c# combo2.DataSource = ((IEnumerable<string>)c.DataSource) .Where(x => x == (string)combo1.SelectedValue); I would like to do a similar thing, but intead of filtering by a second combobox, I would like to filter by the text of a TextBox. (Basically, instead of choosing from a second ComboBox, the user simply enters his filter in to a TextBox). However, it turned out to be not as straight forward as I had hoped it would be. I tried stuff as the following, but failed miserably: cbWohndresse.DataSource = ((IEnumerable<DataSet>)ds) .Where(x => x.Tables["Adresse"].Select("AdrLabel LIKE '%TEST%'")); cbWohndresse.DisplayMember = "Adresse.AdrLabel"; cbWohndresse.ValueMember = "Adresse.adress_id"; ds is the DataSet which I would like to use as filtered DataSource. "Adresse" is one DataTable in this DataSet. It contains a DataColumn "AdrLabel". Now I would like to display only those "AdrLabel", which contain the string from the user input. (Currently, %TEST% replaces the textbox.text.) The above code fails because the lambda expression does not return Bool. But I am sure, there are also other problems (which type should I use for IEnumerable? Now it's DataSet, but Darin used String. But how could I convert a DataSet to a string? Yes, I am as much newbyish as it gets, my experience is "void", and publicly so. So please forgive me my rather stupid questions. Your help is greatly appreciated, because I can't solve this on my own (tried hard already). Thank you very much! Pesche P.S. I am only using Linq to achieve an uncomplicated filter for the ComboBox (avoiding a View). The rest is not based on Linq, but on oldstyle Ado.NET (ds is filled by an SqlDataAdapter), if that's of any importance.

    Read the article

  • Populating ComboBoxDataColumn items and values

    - by MarceloRamires
    I have a "populate combobox", and I'm so happy with it that I've even started using more comboboxes. It takes the combobox object by reference with the ID of the "value set" (or whatever you want to call it) from a table and adds the items and their respective values (which differ) and does the job. I've recently had the brilliant idea of using comboboxes in a gridview, and I was happy to notice that it worked JUST LIKE a single combobox, but populating all the comboboxes in the given column at the same time. ObjComboBox.Items.Add("yadayada"); //works just like ObjComboBoxColumn.Items.Add("blablabla"); But When I started planning how to populate these comboboxes I've noticed: There's no "Values" property in ComboBoxDataColumn. ObjComboBox.Values = whateverArray; //works, but the following doesn't ObjComboBoxColumn.Values = whateverArray; Questions: 0 - How do I populate it's values ? (I suspect it's just as simple, but uses another name) 1 - If it works just like a combobox, what's the explanation for not having this attribute ? -----[EDIT]------ So I've checked out Charles' quote, and I've figured I had to change my way of populating these bad boys. Instead of looping through the strings and inserting them one by one in the combobox, I should grab the fields I want to populate in a table, and set one column of the table as the "value", and other one as the "display". So I've done this: ObjComboBoxColumn.DataSource = DTConfig; //Double checked, guaranteed to be populated ObjComboBoxColumn.ValueMember = "Code"; ObjComboBoxColumn.DisplayMember = "Description"; But nothing happens, if I use the same object as so: ObjComboBoxColumn.Items.Add("StackOverflow"); It is added. There is no DataBind() function. It finds the two columns, and that's guaranteed ("Code" and "Description") and if I change their names to nonexistant ones it gives me an exception, so that's a good sign. -----[EDIT]------ I have a table in SQL Server that is something like code  |  text —————    1    | foo    2    | bar It's simple, and with other comboboxes (outside of gridviews) i've successfully populated looping through the rows and adding the texts: ObjComboBox.Items.Add(MyDataTable.Rows[I]["MyColumnName"].ToString()); And getting every value, adding it into an array, and setting it like: ObjComboBox.Values = MyArray; I'd like to populate my comboboxColumns just as simply as I do with comboboxes.

    Read the article

  • bluetooth file send.

    - by cheesebunz
    i'm new to bluetooth development and i found the 32netfeet . Right now i'm able to search for bluetooth devices nearby and connect to them but how do i send a file e.g SendTest.txt? I tried buttonclick event using the OBEX but i don't understand this is my example code: using InTheHand.Net; using InTheHand.Net.Sockets; using InTheHand.Net.Bluetooth; namespace BluetoothIntheHand { public partial class Form2 : Form { private Guid service = BluetoothService.DialupNetworking; private BluetoothClient bluetoothClient; public Form2() { InitializeComponent(); } private void btnSearch_Click(object sender, EventArgs e) { BluetoothRadio.PrimaryRadio.Mode = RadioMode.Discoverable; BluetoothRadio myRadio = BluetoothRadio.PrimaryRadio; lblSearch.Text = "" + myRadio.LocalAddress.ToString(); bluetoothClient = new BluetoothClient(); Cursor.Current = Cursors.WaitCursor; BluetoothDeviceInfo[] bluetoothDeviceInfo = { }; bluetoothDeviceInfo = bluetoothClient.DiscoverDevices(10); comboBox1.DataSource = bluetoothDeviceInfo; comboBox1.DisplayMember = "DeviceName"; comboBox1.ValueMember = "DeviceAddress"; comboBox1.Focus(); Cursor.Current = Cursors.Default; } private void btnConnect_Click(object sender, EventArgs e) { if (comboBox1.SelectedValue != null) { try { bluetoothClient.Connect(new BluetoothEndPoint((BluetoothAddress)comboBox1.SelectedValue, service)); MessageBox.Show("Connected"); } catch (Exception ex) { MessageBox.Show(ex.Message); } } } private void btnSend_Click(object sender, EventArgs e) { bluetoothClient.Connect(new BluetoothEndPoint((BluetoothAddress)comboBox1.SelectedValue, service)); String addr = "112233445566"; Uri uri = new Uri("obex://"+@"SendTest.txt"); ObexWebRequest req= new ObexWebRequest(uri); ObexWebResponse rsp; } I found the guide but don't really know how to convert to C# ' The host part of the URI is the device address, e.g. IrDAAddress.ToString(), ' and the file part is the OBEX object name. Dim addr As String = "112233445566" Dim uri As New Uri("obex://" & addr & "/HelloWorld2.txt") Dim req As New ObexWebRequest(uri) Using content As Stream = req.GetRequestStream() ' Using a StreamWriter to write text to the stream... Using wtr As New StreamWriter(content) wtr.WriteLine("Hello World GetRequestStream") wtr.WriteLine("Hello World GetRequestStream 2") wtr.Flush() ' Set the Length header value req.ContentLength = content.Length End Using ' In this case closing the StreamWriter also closed the Stream, but ... End Using Dim rsp As ObexWebResponse = CType(req.GetResponse(),ObexWebResponse) Console.WriteLine("Response Code: {0} (0x{0:X})", rsp.StatusCode)

    Read the article

  • Unselect Databound Combobox Winforms .NET

    - by joedotnot
    The problem: combobox is databound to a DataView, first item in the dataview is DataRowView whose fields are DBNull.Value; Combo DropdownStyle = ComboBoxStyle.DropDownList Loads fine, displays fine, selects fine, problem is to Unselect via code. Setting the SelectedIndex to 0 throws an exception. (Setting to -1 is a no-no as per msdn doco that says dont set SelectedIndex=-1 if databound) So how to unselect without throwing an exception ? For now i wrapped it into a try/catch to just ignore the error! EDIT: As asked by Hubeza, i worked on sample code to post. Did a stripped down version of the original code in C# (original is in VB.NET) and could NOT reproduce it either. Converted to VB.NET and could NOT reproduce it either ! In other words, SelectedIndex = 0 does work in the stripped down version! Currently further investigating what else could be wrong with the original code. EDIT2: Case Closed. Call me a stupid fool if you like, and apologies for wasting anyone's time - The error was originating from MyComboBox_SelectedIndexChanged event, which i neglected to check ! May as well post the sample in case anyone finds useful. private void LoadComboMethod() { DataTable dtFruit = new DataTable("FruitTable"); //define columns DataColumn colID = new DataColumn(); colID.DataType = typeof(Int32); //VB.NET GetType(Int32) colID.ColumnName = "ID"; DataColumn colDesc = new DataColumn(); colDesc.DataType = typeof(String); colDesc.ColumnName = "Description"; //add columns to table dtFruit.Columns.AddRange(new DataColumn[] { colID, colDesc }); //add rows DataRow row = dtFruit.NewRow(); row[colID] = 1; row[colDesc] = "Apples"; dtFruit.Rows.Add(row); row = dtFruit.NewRow(); row[colID] = 1; row[colDesc] = "Bananas"; dtFruit.Rows.Add(row); row = dtFruit.NewRow(); row[colID] = 1; row[colDesc] = "Oranges"; dtFruit.Rows.Add(row); //add extra blank row. DataRowView drv = dtFruit.DefaultView.AddNew(); drv.EndEdit(); //Bind combo box DataView dv = new DataView(dtFruit); dv.Sort = "ID ASC"; //ensure blank item on top cboFruit.DataSource = dv; cboFruit.DisplayMember = "Description"; cboFruit.ValueMember = "ID"; } private void UnselectComboMethod() { if (cboFruit.SelectedIndex > 0) { cboFruit.SelectedIndex = 0; } else { MessageBox.Show("no fruit selected"); } }

    Read the article

< Previous Page | 1 2 3  | Next Page >