Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
B

Brett Slaski

@Brett Slaski
About
Posts
21
Topics
7
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • How to open new form
    B Brett Slaski

    It wont? Please explain? It's what I use and I don't use vb.net. Thank you, Brett

    C# tutorial question career

  • Getting the command line as a whole
    B Brett Slaski

    That's ok, it's easily parsed out. Thank you much! Brettski

    C# csharp json question learning

  • How to open new form
    B Brett Slaski

    Using some event to call it up (command button, etc.) or just opening in your constructor of form one: System.Windows.Forms.Form form2 = New myNamspace.Form2; Form2.show(); Brettski

    C# tutorial question career

  • Getting the command line as a whole
    B Brett Slaski

    Greetings, I really like the new command line parsing in C# and that is separates paramerters by space, it has been very useful. Of course I have a need to grab the command line as a whole as it was sent to the application and not cutup by it's spaces. Is there any way to do this in C#? The result should be the same as you get from command$ in vb. I would love to change the parameter but it's being sent from another aplication which I cannot change. Thank you in advance for any assistance. Brett

    C# csharp json question learning

  • comobox.SelectedValue
    B Brett Slaski

    webhay wrote: combobox.DataSource = ds.Tables[0]; combobox.DisplayMember = ds.Tables[0].Columns["Client_Name"].ToString(); combobox.ValueMember = ds.Tables[0].Columns["Client_ID"].ToString(); You are not properly binding your combobox. Try this: combobox.DataSource = ds; combobox.DisplayMember = "TableName.Client_Name"; combobox.ValueMember = "TableName.Client_ID"; Note it is not recomended to use `ds.TableName' for the datasource.

    C# help

  • Simple HTML editor for winforms
    B Brett Slaski

    Thanks, Most of what I have seen are asp.net controls. Most of the winforms stuff is overkill. I will take a look at the links.

    C# csharp html database winforms question

  • comobox.SelectedValue
    B Brett Slaski

    How are you loading the combo?

    C# help

  • comobox.SelectedValue
    B Brett Slaski

    You need to cast the value. E.g. int theInt = (int) ComboBox.selectedValue;

    C# help

  • Simple HTML editor for winforms
    B Brett Slaski

    I am building an admin application for our website using winforms and C#. Users (who don't know html) are required to maintain content for the site. I would like to give them the ability to bold, underline, create links, etc. for the site. All content in stored in a database as html. Is there a component available for this that isn't a full blown html editor? I don't need to build pages with it, just edit text. Thanks in advance, Brett

    C# csharp html database winforms question

  • Inheriting User Controls
    B Brett Slaski

    True enough, how simple. Protected is probably a much safer bet though.

    C# winforms

  • Inheriting User Controls
    B Brett Slaski

    Greetings, When I inherit from a user control I would like to rearange the controls of the base control on the new control. E.g. I have to list boxes side by side on the base control. I would like to change that to one list box above the other on the inherited control. The code for these controls are the same and I would like to get reuse out of this if possible. Thank you, Brett

    C# winforms

  • Receiving NoNullAllowedException setting SelectedValue from code.
    B Brett Slaski

    It was suggested to me to use SelectedIndex instead of SelectedValue in my btnNew_Click method: private void btnNew_Click(object sender, System.EventArgs e) { int i = Convert.ToInt32(this.comboBox.SelectedValue); bm.AddNew(); this.comboBox.SelectedValue = sid; } >>>> Change to: private void btnNew_Click(object sender, System.EventArgs e) { int i = this.comboBox.SelectedIndex; bm.AddNew(); this.comboBox.SelectedIndex = sid; } Which this works great. I can preset the ComboBox to a value and it will be recognized by DataBinding, which isn't the case when you use SelectedValue. I just wonder how I would handle this if I don't know the index? If I have a langauge selector to default to the users preferred language, I know "EN" or "SP" but I don't know their index value. Is there a way to get this? Brett Slaski

    C# help tutorial question

  • Receiving NoNullAllowedException setting SelectedValue from code.
    B Brett Slaski

    I am having some trouble with setting a value to ComboBox.SelectedValue and then saving that value using DataBinding. Example: // There are five controls on a form, 1 ComboBox (comboBox), 2 TextBoxes (tbx1, tbx2) and 2 buttons (btnNew, btnSave) DataSet dsFillCombo; DataSet ds1; // I fill each DataSet using separate data adapters ... // The Combo is Bound like this comboBox.DataSource = dsFillCombo; comboBox.DisplayMember = "sectionIds.sectionName"; comboBox.ValueMember = "sectionIds.sectionId"; // So far, pretty basic. Now I bind the controls on the form to my other // DataSet tbx1.DataBinding.Add("Text", ds1, "users.fName"); tbx2.DataBinding.Add("Text", ds1, "users.lName"); comboBox.DataBinding.Add("SelectedValue", ds1, "users.sectionId"); BindingManagerBase bm = BindingContext[ds1, "users"]; // Still pretty basic, I could add more buttons to change the record // position, and the values // in the form controls would change with the data rows. // Now for my issue! // For the btnNew I want to add a new record to the dataset and set the // comboBox to the same value that it is currently. private void btnNew_Click(object sender, System.EventArgs e) { int i = Convert.ToInt32(this.comboBox.SelectedValue); bm.AddNew(); this.comboBox.SelectedValue = sid; } // Now I click the Save button and... private void btnSave_Click(object sender, System.EventArgs e) { bm.EndCurrentEdit(); } As soon as I click btn_Save an Exception is thrown: System.NoNullAllowedException: Column 'sectionId' does not allow nulls. ... If I actually select a new value using the comboBox then the new record is saved without an issue. Is there a way to set the SelectedValue of a ComboBox from code and have that value recongnized by DataBinding? Thank you for any assistance. Brett Slaski

    C# help tutorial question

  • Question on simple binding
    B Brett Slaski

    I tried someting new. I created a new UserControl, but instead of inheriting from System.Windows.Forms.UserControl I inherited from System.Windows.Forms.ComboBox (isn't this now a customcontrol??) Anyway this new user control binds without any problems. I bind to lp2.SelectedValue Here are the basics. public class lp2 : System.Windows.Forms.ComboBox { // Our Variables private SqlDataAdapter dataAdapter; private SqlConnection sqlConnection; private DataSet dataset; /// /// Required designer variable. /// private System.ComponentModel.Container components = null; public lp2() { // This call is required by the Windows.Forms Form Designer. InitializeComponent(); // TODO: Add any initialization after the InitializeComponent call sqlConnection = Utilities.dbUtilities.getWebDbCn(); string selectCommand = "select * from lang"; dataset = new DataSet(); dataAdapter = new SqlDataAdapter(selectCommand, sqlConnection); dataAdapter.Fill(dataset, "lang"); this.DataSource = dataset; this.DisplayMember = "lang.langText"; this.ValueMember = "lang.lang"; } } My other UserControl is simular except I have a ComboBox added to the class where this class inherits ComboBox. Now I guess I need to figure out how to get the older UserControl to work since I will be back to the issue when I have a UserControl with more than one control or component on it. Are there things I must do in a UserControl to make sure I can bind to it's properties?

    C# question wpf wcf

  • Question on simple binding
    B Brett Slaski

    I am sorry, I don't see how this answers my question. The combobox bindings are being handled in the control. It is the 'simple data binding' to the UserControl's property I can't get to work. I don't think I would pull a BindingContext from [UserControl.myProperty] would I? I don't think I would get a useful binding manager that way. Thank you very much for helping me through this.

    C# question wpf wcf

  • Question on simple binding
    B Brett Slaski

    Thank you. Before I dive into changing some things around, I have a question on the BindingContext. There are 3 TextBoxes and 2 UserControls which are bound to the same DataSet.Table (fyi, my dataset is typed). Would the way I get the BindingContext effect the binding between these three different controls? In other words, the binding is working fine on the the 3 TextBoxes but is not working on the 2 UserControls. If I: string o=""; BindingManagerBase bindingManager = this.BindingContext[DataSet, "table"]; foreach(Binding b in bindingManager.Bindings) { o += b.Control.ToString() + "\n"; } MessageBox.Show(o); The TextBox binding show, but the UserControls do not. And obviously, the Text boxes are bound and change with .Position property. Is there anything other that a set and get required on the UserControl for the binding to work?

    C# question wpf wcf

  • Question on simple binding
    B Brett Slaski

    Correct, that binding will not work, hence my dilemma. Neither of these work: myUserControl1.DataBindings.Add("SelectedValue", dataSet1, "DataTable1"); myUserControl1.DataBindings.Add( new System.Windows.Forms.Bindings("SelectedValue", dataSet1, "DataTable1")); Note, setting a value directly to the UserControl property does work. Thanks for your assistence, Brett

    C# question wpf wcf

  • Question on simple binding
    B Brett Slaski

    Thanks for the response. I has more of an explaination here but didn't receive any replies. I have created a UserControl which contains a ComboBox. This combo box if filled with data in the controls constructor. I created a public property to expose the ComboBox.SelectedValue property so I may bind to it from forms which use the control. The bindings never work. The debugger doesn't compain at all, and the values in the UserControl's ComboBox never changes with the CurrencyManager.Position changes.

    C# question wpf wcf

  • Question on simple binding
    B Brett Slaski

    Can I simple-bind an object that derives from System.Windows.Forms.UserControls class? Thank you, Brett

    C# question wpf wcf

  • Using DataBinding with a user control
    B Brett Slaski

    I created a user control which contains a combobox for table lookups. It basically sets up a DataAdapter and DataSet and binds it to the combobox. For access to the SelectedValue from forms that will use the control I added: public object selectedValue { get { return this.combo.SelectedValue; } set { this.combo.SelectedValue = value; } } The problem that I am having is when I add the user control to form and use simple binding on the property selectedValue, the value isn't updated. It will update if I set it directly. See below. Works (from a new form) this.comboSelector.selectedValue = 100; // The comboSelector will update with the corrisponding data. Not Working (from a new form) this.comboSelector.DataBindings.Add(new System.Windows.Binding("selectedValue", dataSet, "table.column")); I also tried: this.comboSelector.DataBindings.Add("selectedValue", dataSet, "table.column")); When the Currency Manager's postion is chaged these values are not updated. What am I missing? Thanks in advance. Brett Slaski

    C# wpf wcf help question announcement
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups