dataGridViewComboBoxColumn的数据源为一dataView的mf_no列,当用户选定dataGridViewComboBoxColumn中的某值时,根据该值在dataView中找到与其对应的mf_name列值并用其
填充dataGridView表格的“厂名”列(即当用户选择厂商编号时自动显示厂名)dataGirdViewComboBox好象没有象winform中的comboBox控件一样有很多事件,我如何判断用户是否选定了某值呢?
填充dataGridView表格的“厂名”列(即当用户选择厂商编号时自动显示厂名)dataGirdViewComboBox好象没有象winform中的comboBox控件一样有很多事件,我如何判断用户是否选定了某值呢?
解决方案 »
- winform中怎么用HttpWebRequest Post登录信息到一个网页 并返回信息
- C#打洞过程
- c# 中的排序小问题
- C#2005 TreeView的一些问题
- 有关socket通信..c# web win2003 设置
- [我不是要盗版]Reflector报#GUID heap has invalid size
- ----紧急求救,关于udp的广播的问题,有代码和注释,我的程序就是不能发送和接收,也不能干净的退出去,不知道为什么?----
- 高手解答一下,水晶报表-引用字段值时,出现问题????
- 大虾们!我想问一个关于多层结构的问题,业务外观与业务逻辑之间是什么关系
- 如何取得dll中函数的原型?
- ****** 问一个低级问题? 我在创建项目(asp.net)时失败, 错误提示为: 与服务器的连接 被重置。
- 请教一个关于反射的问题``动态创建某个枚举的变量
if (currentx == 0)
{
try
{
inventoryIDSelected = Convert.ToInt32(shoppingCartGridView.CurrentCell.Value.ToString()); if (inventoryIDSelected != 0)
{
thisconnection.Open(); SqlDataAdapter thisAdapter = new SqlDataAdapter("Select ShoppingCart.inventoryID,size,color,averageCost,quantityOnHand from InventoryItem,ShoppingCart where ShoppingCart.inventoryID='" + inventoryIDSelected + "' and InventoryItem.productID=ShoppingCart.productID", thisconnection);
SqlCommandBuilder thisBuilder = new SqlCommandBuilder(thisAdapter); DataSet thisDataSet = new DataSet();
thisAdapter.Fill(thisDataSet, "CatalogProduct"); thisconnection.Close();
}
}
catch (Exception)
{
// MessageBox.Show(ee.Message);
}
}下面这些是按要求,把从数据库中选择出来的列填充到datagridview中。你可以参考一下。你看看能否由这两段代码把你的东西,弄出来。应该问题不大。如果不行,我们再联系。我把代码改过来,再发到这上面,可以吗? thisconnection.Open(); SqlDataAdapter thisAdapter = new SqlDataAdapter("Select inventoryID,productID,cartID,productQuantity,shoppingDate,price from ShoppingCart ", thisconnection);
SqlCommandBuilder thisBuilder = new SqlCommandBuilder(thisAdapter); DataSet thisDataSet = new DataSet();
thisAdapter.Fill(thisDataSet, "ShoppingCart"); //productDataGridView.DataBindings = thisDataSet.Tables["CatalogProduct"];
shoppingCartGridView.DataSource = thisDataSet.Tables["ShoppingCart"];
thisconnection.Close();
DataGridViewComboBoxEditingControl类继承自ComboBox类,事件都差不多的.例如:下面的代码示例演示如何使用 DataGridView.EditingControlShowing 事件处理程序添加 DataGridViewComboBoxEditingControl 事件的处理程序。在这个示例中,编辑控件被强制转换为 ComboBox 以处理 ComboBox.SelectedIndexChanged 事件。
private DataGridView dataGridView1 = new DataGridView();private void AddColorColumn()
{
DataGridViewComboBoxColumn comboBoxColumn =
new DataGridViewComboBoxColumn();
comboBoxColumn.Items.AddRange(
Color.Red, Color.Yellow, Color.Green, Color.Blue);
comboBoxColumn.ValueType = typeof(Color);
dataGridView1.Columns.Add(comboBoxColumn);
dataGridView1.EditingControlShowing +=
new DataGridViewEditingControlShowingEventHandler(
dataGridView1_EditingControlShowing);
}private void dataGridView1_EditingControlShowing(object sender,
DataGridViewEditingControlShowingEventArgs e)
{
((ComboBox)e.Control).SelectedIndexChanged +=
new EventHandler(ComboBox_SelectedIndexChanged);
}private void ComboBox_SelectedIndexChanged(object sender, EventArgs e)
{
((ComboBox)sender).BackColor = (Color)((ComboBox)sender).SelectedItem;
}