你可以看到列类型中有重复的舞蹈。当我点击自动过滤器行时,舞蹈被读了两次。如何丢弃它有一个相同的字符串?所以在repositoryitembox中只有一个舞蹈
private void gridView1_CustomRowCellEdit(object sender, CustomRowCellEditEventArgs e)
{
repositoryItemComboBox1.Items.Clear();
for (int i = 0; i < gridView1.RowCount; i++)
{
var genre = gridView1.GetDataRow(i)["genre"].ToString();
//if (genre.Contains("Dance"))
//{
// repositoryItemComboBox1.Items.Add("!!!");
//}
repositoryItemComboBox1.Items.Add(genre);
}
编辑:我不想按字符串检查genre.contains("Dance")
。
答案 0 :(得分:0)
您不会检查字符串类型,而是针对您已有的组合框项目。因此:
private void gridView1_CustomRowCellEdit(object sender, CustomRowCellEditEventArgs e)
{
repositoryItemComboBox1.Items.Clear();
for (int i = 0; i < gridView1.RowCount; i++)
{
var genre = gridView1.GetDataRow(i)["genre"].ToString();
if(!repositoryItemComboBox1.Items.Contains(genre))
{
repositoryItemComboBox1.Items.Add(genre);
}
}
}
答案 1 :(得分:0)
你可以通过使用Combobox1.Items.Contains函数
来完成 CREATE TRIGGER IO_ABC_INSERT ON TABLEA
INSTEAD OF INSERT
AS
BEGIN
Declare @a[varchar](50),@b[varchar](50),@c[varchar](50),@d[varchar](50),@e[varchar](50)
-- declare a cursor
DECLARE insert_cursor CURSOR FOR
SELECT [a]
,[b]
,[c]
,[d]
,[e]
FROM TableA
-- open cursor and fetch first row into variables
OPEN insert_cursor
FETCH NEXT FROM insert_cursor into @a,@b,@c,@d,@e
-- check for a new row
WHILE @@FETCH_STATUS=0
BEGIN
-- do complex operation here
Insert into TableB
SELECT @a,@b,@c,@d,@e
-- get next available row into variables
FETCH NEXT FROM insert_cursor into @a,@b,@c,@d,@e
END
close insert_cursor
Deallocate insert_cursor
END