To reproduce, run the code.
Observed:
System.Argument OutOfRangeExcep tion was unhandled
Message="Invali dArgument=Value of '0' is not valid for
'SelectedIndex' .\r\nParameter name: SelectedIndex"
t2.c1 contains legal value.
Why this error occurs ?
How to fix ?
Andrus.
using System.Windows. Forms;
using System.Data;
using System;
class testForm : Form {
testForm() {
DataTable t = new DataTable();
t.Columns.Add(" displaymember") ;
t.Columns.Add(" valuemember");
t.Rows.Add("low er", "l");
ComboBox comboBox1 = new ComboBox();
comboBox1.Displ ayMember = "displaymember" ;
comboBox1.Value Member = "valuemembe r";
comboBox1.DataS ource = t;
comboBox1.AutoC ompleteSource = AutoCompleteSou rce.ListItems;
comboBox1.AutoC ompleteMode = AutoCompleteMod e.SuggestAppend ;
DataTable t2 = new DataTable();
t2.Columns.Add( "c1");
t2.Rows.Add("l" );
comboBox1.DataB indings.Add("Se lectedValue", t2, "c1");
Controls.AddRan ge(new Control[] { comboBox1 });
}
[STAThread]
static void Main() {
Application.Run (new testForm());
}
} 5 16503
It isn't legal if it's a string.
--
HTH,
Kevin Spencer
Microsoft MVP
Printing Components, Email Components,
FTP Client Classes, Enhanced Data Controls, much more.
DSI PrintManager, Miradyne Component Libraries: http://www.miradyne.net
"Andrus" <ko********@hot .eewrote in message
news:eM******** ******@TK2MSFTN GP05.phx.gbl...
To reproduce, run the code.
Observed:
System.Argument OutOfRangeExcep tion was unhandled
Message="Invali dArgument=Value of '0' is not valid for
'SelectedIndex' .\r\nParameter name: SelectedIndex"
t2.c1 contains legal value.
Why this error occurs ?
How to fix ?
Andrus.
using System.Windows. Forms;
using System.Data;
using System;
class testForm : Form {
testForm() {
DataTable t = new DataTable();
t.Columns.Add(" displaymember") ;
t.Columns.Add(" valuemember");
t.Rows.Add("low er", "l");
ComboBox comboBox1 = new ComboBox();
comboBox1.Displ ayMember = "displaymember" ;
comboBox1.Value Member = "valuemembe r";
comboBox1.DataS ource = t;
comboBox1.AutoC ompleteSource = AutoCompleteSou rce.ListItems;
comboBox1.AutoC ompleteMode = AutoCompleteMod e.SuggestAppend ;
DataTable t2 = new DataTable();
t2.Columns.Add( "c1");
t2.Rows.Add("l" );
comboBox1.DataB indings.Add("Se lectedValue", t2, "c1");
Controls.AddRan ge(new Control[] { comboBox1 });
}
[STAThread]
static void Main() {
Application.Run (new testForm());
}
}
Kevin,
thank you.
The code does not set SelectedIndex as all.
Why .NET tries to set SelectedIndex to invalid value ?
Andrus.
It isn't legal if it's a string.
>> Observed: System.Argumen tOutOfRangeExce ption was unhandled Message="Inval idArgument=Valu e of '0' is not valid for 'SelectedIndex '.\r\nParameter name: SelectedIndex"
t2.c1 contains legal value. Why this error occurs ? How to fix ?
Andrus.
using System.Windows. Forms; using System.Data; using System; class testForm : Form {
testForm() { DataTable t = new DataTable(); t.Columns.Add(" displaymember") ; t.Columns.Add(" valuemember"); t.Rows.Add("low er", "l");
ComboBox comboBox1 = new ComboBox(); comboBox1.Displ ayMember = "displaymember" ; comboBox1.Value Member = "valuemembe r"; comboBox1.DataS ource = t; comboBox1.AutoC ompleteSource = AutoCompleteSou rce.ListItems; comboBox1.AutoC ompleteMode = AutoCompleteMod e.SuggestAppend ;
DataTable t2 = new DataTable(); t2.Columns.Add( "c1"); t2.Rows.Add("l" ); comboBox1.DataB indings.Add("Se lectedValue", t2, "c1"); Controls.AddRan ge(new Control[] { comboBox1 }); }
[STAThread] static void Main() { Application.Run (new testForm()); } }
Andrus wrote:
To reproduce, run the code.
Observed:
System.Argument OutOfRangeExcep tion was unhandled
Message="Invali dArgument=Value of '0' is not valid for
'SelectedIndex' .\r\nParameter name: SelectedIndex"
t2.c1 contains legal value.
Why this error occurs ?
How to fix ?
Andrus.
using System.Windows. Forms;
using System.Data;
using System;
class testForm : Form {
testForm() {
DataTable t = new DataTable();
t.Columns.Add(" displaymember") ;
t.Columns.Add(" valuemember");
t.Rows.Add("low er", "l");
ComboBox comboBox1 = new ComboBox();
comboBox1.Displ ayMember = "displaymember" ;
comboBox1.Value Member = "valuemembe r";
comboBox1.DataS ource = t;
comboBox1.AutoC ompleteSource = AutoCompleteSou rce.ListItems;
comboBox1.AutoC ompleteMode = AutoCompleteMod e.SuggestAppend ;
DataTable t2 = new DataTable();
t2.Columns.Add( "c1");
t2.Rows.Add("l" );
comboBox1.DataB indings.Add("Se lectedValue", t2, "c1");
Controls.AddRan ge(new Control[] { comboBox1 });
}
[STAThread]
static void Main() {
Application.Run (new testForm());
}
}
You can't select a specific item from a combobox that doesn't contain
any items at all.
You haven't databound the combobox, so it doesn't contain any items.
--
Göran Andersson
_____ http://www.guffa.com
Andrus wrote:
Kevin,
thank you.
The code does not set SelectedIndex as all.
Why .NET tries to set SelectedIndex to invalid value ?
Andrus.
You are setting the SelectedValue property. That will basically look for
the value among the items, and set the SelectedIndex property for the
matching item.
--
Göran Andersson
_____ http://www.guffa.com
Andrus wrote:
To reproduce, run the code.
Observed:
System.Argument OutOfRangeExcep tion was unhandled
Message="Invali dArgument=Value of '0' is not valid for
'SelectedIndex' .\r\nParameter name: SelectedIndex"
t2.c1 contains legal value.
Why this error occurs ?
How to fix ?
Andrus.
using System.Windows. Forms;
using System.Data;
using System;
class testForm : Form {
testForm() {
DataTable t = new DataTable();
t.Columns.Add(" displaymember") ;
t.Columns.Add(" valuemember");
t.Rows.Add("low er", "l");
ComboBox comboBox1 = new ComboBox();
comboBox1.Displ ayMember = "displaymember" ;
comboBox1.Value Member = "valuemembe r";
comboBox1.DataS ource = t;
comboBox1.AutoC ompleteSource = AutoCompleteSou rce.ListItems;
comboBox1.AutoC ompleteMode = AutoCompleteMod e.SuggestAppend ;
DataTable t2 = new DataTable();
t2.Columns.Add( "c1");
t2.Rows.Add("l" );
comboBox1.DataB indings.Add("Se lectedValue", t2, "c1");
Controls.AddRan ge(new Control[] { comboBox1 });
}
[STAThread]
static void Main() {
Application.Run (new testForm());
}
}
Hi,
This is *totally* a guess, because I haven't tried your code, but try moving
this line:
comboBox1.DataS ource = t;
So it immediately follows this line:
ComboBox comboBox1 = new ComboBox();
--
Tom Spink
University of Edinburgh This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: cwizard |
last post by:
I'm calling on a function from within this form, and there are values set
but every time it gets called I get slammed with a run time error...
document.frmKitAmount.txtTotalKitValue is null or not an object... the
function is like so:
function calc_total()
{
var x,i,base,margin,total,newmargin,newtotal;
base = document.frmKitAmount.txtTotalKitValue.value;
margin = document.frmKitAmount.margin.value/100;
|
by: ???????J |
last post by:
Javascript may inquire the push down menu value, can I inquire the
description?
The following example, the variable($answer) can be get the menu1's
value.
For example, if I select first data, the menu1's value would be 1.
Therefore ($answer) would be 1.
But If want using javascript get the description(ABC),which javascript
command can do it?
|
by: niyong |
last post by:
--
Hop@Ni
|
by: hodari |
last post by:
The compiler complains that zero is not acceptable value for selectedIndex.
What I am doing is loading up the combo box with the data from a dataset and
then setting the SelectedIndex value to zero thus forcing the first record to
be selected.
This is an untyped data set and unbound...
Here is a snippet:
private void frmCustomer_Load(object sender, EventArgs e)
|
by: Benedict Teoh |
last post by:
I created a dropdownlist containing day, month and year field and expose a property to assign a date. When I call from a aspx page and assign the value, the new date is not displayed until a submit is performed.
How do I force the usercontrol to display the newly assigned date? I don't have this problem if I place the two dropdownlist and the year field directly on the aspx page.
| |
by: JSantora |
last post by:
Essentially, InsertAT is broken!
For the past couple of hours, I've been getting this "Parameter name:
'-2147483550' is not a valid value for 'index'." error.
Apparently, its caused by having manually inserted a row in the table
bound to the Combo box. The InsertAt Method of adding a row just does
not work.
Hope this helps anyone with this problem.
john
|
by: Jim Carlock |
last post by:
Does a SELECT element (listbox) need to be inside
a FORM element?
The code I'm playing with:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!-- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
by: Harris |
last post by:
Dear all,
I have the following codes:
======
public enum Enum_Value
{
Value0 = 0,
Value1 = 10,
|
by: kang jia |
last post by:
hi
currently i am editing signup page, when user enter deupicated NRIC and click signup, they will go to do_signuppage and read the error message and then after 5 seconds, they will be redirected to signup page again, however, this time they go back, all the correct value will be remain. how should i achieve this.
my current code for singup.php is like this
<html>
<head>
<link rel="stylesheet" type="text/css" href="gallery.css" />
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |