我编写了用于删除列表项的函数: private void grid1_Drop(object sender,RoutedEventArgs e) { TextBlock textBlock = e.Source as TextBlock; Console.WriteLine("将项目拖放到网格列:{0}行:{1}", Grid.GetColumn(textBlock),Grid.GetRow(textBlock));
DataObject item = (((DragEventArgs)e).Data) as DataObject;
ListBoxItem listItem = item.GetData(typeof(ListBoxItem)) as ListBoxItem;
Window1 second = new Window1();
second.ShowDialog();
//textBlock.Height = textBlock.Height*second.getBrCasova();
Grid.SetRowSpan(textBlock, second.getBrCasova());
textBlock.Background = Brushes.Gray;
string pom = "";
if(second.getBrCasova() == 1)
textBlock.VerticalAlignment = System.Windows.VerticalAlignment.Stretch;
else
for (int i = 0; i < second.getBrCasova();i++ )
pom += "\n";
textBlock.Text = pom + listItem.Content.ToString() + "\n" + second.getUcionica();
textBlock.TextAlignment = System.Windows.TextAlignment.Center;
textBlock.Margin = new Thickness(0,0,2,2.5);
}
问题是,如果我得到Grid.SetRowSpan(textBlock,second.getBrCasova()),second.getBrCasova&gt; 2,则不会删除单元格之间的边框。
这部分xaml显示了我如何制作文本块表:
<Border Grid.Column="1" Grid.Row="1" BorderBrush="Black" BorderThickness="0,0,2,2" Background="Transparent" />
<Border Grid.Column="2" Grid.Row="1" BorderBrush="Black" BorderThickness="0,0,2,2" Background="Transparent" />
<Border Grid.Column="3" Grid.Row="1" BorderBrush="Black" BorderThickness="0,0,2,2" Background="Transparent" />
<Border Grid.Column="4" Grid.Row="1" BorderBrush="Black" BorderThickness="0,0,2,2" Background="Transparent" />
<Border Grid.Column="5" Grid.Row="1" BorderBrush="Black" BorderThickness="0,0,2,2" Background="Transparent" />
<Border Grid.Column="6" Grid.Row="1" BorderBrush="Black" BorderThickness="0,0,2,2" Background="Transparent" />
<TextBlock Grid.Row="1" Grid.Column="1" Name="TextBlock11" AllowDrop="True" PreviewMouseLeftButtonDown="TextBlock11_PreviewMouseLeftButtonDown"></TextBlock>
<!--<Rectangle Grid.Column="2"
Grid.Row="1"
Stroke="Black"
Fill="Transparent" />-->
<TextBlock Grid.Row="1" Grid.Column="2" AllowDrop="True"></TextBlock>
<!--<Rectangle Grid.Column="3"
Grid.Row="1"
Stroke="Black"
Fill="Transparent" />-->
<TextBlock Grid.Row="1" Grid.Column="3" AllowDrop="True"></TextBlock>
<!--<Rectangle Grid.Column="4"
Grid.Row="1"
Stroke="Black"
Fill="Transparent" />-->
<TextBlock Grid.Row="1" Grid.Column="4" AllowDrop="True"></TextBlock>
...
如何从功能中删除此边框? 提前谢谢。