关于DataGridView绑定数据源后未设置的列不显示
2011-07-21 23:30
1286 查看
把datagridview 数据源转换为绑定的数据源
public class PlanInfo
{
/// <summary>
/// 计划ID
/// </summary>
public int a { get; set; }
/// <summary>
/// 序号
/// </summary>
public int b { get; set; }
/// <summary>
/// 发车
/// </summary>
public string c { get; set; }
}
List<PlanInfo> planInfos1 = new List<PlanInfo>();
dataGridview 绑定planInfos1,显示列为计划ID,序号。现访问其他列的数据
List<PlanInfo> ps = dataGridview.DataSource as List<PlanInfo>;
PlanInfo p = ps[e.RowIndex];
this.c = p.a;
this.c = p.c;
private void dataGridview_CellContextMenuStripNeeded(object sender, DataGridViewCellContextMenuStripNeededEventArgs e)
{
foreach (DataGridViewRow dr in this.dgvOnVehicle.Rows)
{
dr.Selected = false;
}
this.dataGridview.Rows[e.RowIndex].Selected = true;
DataGridView dgv = (DataGridView)sender;
List<PlanInfo> ps = dgv.DataSource as List<PlanInfo>;
if (ps != null)
{
PlanInfo p = ps[e.RowIndex];
if (p == null) return;
planInfoMenu = p;
this.a = p.a;
this.b = p.b;
this.c = p.c;
}
catch (Exception ex)
{
}
}
}
public class PlanInfo
{
/// <summary>
/// 计划ID
/// </summary>
public int a { get; set; }
/// <summary>
/// 序号
/// </summary>
public int b { get; set; }
/// <summary>
/// 发车
/// </summary>
public string c { get; set; }
}
List<PlanInfo> planInfos1 = new List<PlanInfo>();
dataGridview 绑定planInfos1,显示列为计划ID,序号。现访问其他列的数据
List<PlanInfo> ps = dataGridview.DataSource as List<PlanInfo>;
PlanInfo p = ps[e.RowIndex];
this.c = p.a;
this.c = p.c;
private void dataGridview_CellContextMenuStripNeeded(object sender, DataGridViewCellContextMenuStripNeededEventArgs e)
{
foreach (DataGridViewRow dr in this.dgvOnVehicle.Rows)
{
dr.Selected = false;
}
this.dataGridview.Rows[e.RowIndex].Selected = true;
DataGridView dgv = (DataGridView)sender;
List<PlanInfo> ps = dgv.DataSource as List<PlanInfo>;
if (ps != null)
{
PlanInfo p = ps[e.RowIndex];
if (p == null) return;
planInfoMenu = p;
this.a = p.a;
this.b = p.b;
this.c = p.c;
}
catch (Exception ex)
{
}
}
}
相关文章推荐
- 关于DataGridView绑定数据源后未设置的列不显示
- C#窗体:关于DataGridView的数据源绑定字符串两个值得注意的问题
- 章鱼哥出品—VB.NET DataGridView绑定数据源 "与货币管理器的位置关联的行不能设置为不可见" 问题的解决
- datagridview显示绑定数据源的某几个属性的方法
- 关于datagridview自动增加行高度和显示全部内容的设置
- 章鱼哥出品—VB.NET DataGridView绑定数据源 "与货币管理器的位置关联的行不能设置为不可见" 问题的解决
- 对绑定到数据源的文本框如何设置其显示格式
- WinForm中,将DataGridView中的某一行某一列设置为下拉列表时候单独绑定数据源
- winform datagridview 不显示默认第一列 不显示未绑定列 数据源发生改变时自动更新
- 如何限制.net2.0 DataGridView绑定数据源后显示所有属性列
- 刚发现了一个问题,关于vs2005 datagridview的,我发现在设计行标头的HeaderCell.Value的时候要是设置RowTemplate.Height 的值>= 17则行标头的那个黑三角就显示出来了,要是小于17就不能显示了,想问问大家,是怎么回事?
- 关于DataGridView的数据源绑定字符串两个值得注意的问题
- 关于DataGridView的数据源绑定字符串两个值得注意的问题
- 关于datagridview自动增加行高度和显示全部内容的设置
- 关于DataGridView的数据源绑定字符串两个值得注意的问题
- 关于是的datagridview根据数据源显示自己想要的对应文本内容
- 关于DataGridView的数据源绑定字符串两个值得注意的问题
- DataGridView设置不自动显示数据库中未绑定的列
- 关于C# DATAGRIDVIEW select 后绑定数据源顺序混乱的问题
- 关于DataGridView的数据源绑定字符串两个值得注意的问题