Click here to Skip to main content
15,886,137 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Guys,

When you select a row in a datagrid it does that blue highlight thing right? But it doesn't highlight the whole width of the row. What can i do to make it highlight the whole row and not just the text in the row? See this is what happens when a row is selected in my datagrid in wpf

XML
<Style.Triggers>
            <Trigger Property="IsSelected" Value="True">
                <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}" />
                <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}" />
                <Setter Property="BorderBrush" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}" />
                <Setter Property="VerticalAlignment" Value="Stretch"/>
                <Setter Property="VerticalContentAlignment" Value="Center"/>
            </Trigger>
            <Trigger Property="IsKeyboardFocusWithin" Value="True">
                <Setter Property="BorderBrush" Value="{DynamicResource {x:Static DataGrid.FocusBorderBrushKey}}" />
            </Trigger>
        </Style.Triggers>
    </Style>


Please help me.

Thanks in Advance.
Posted
Updated 13-Jul-11 0:24am
v3

using System.Drawing;

protected void LinkButton1_Click(object sender, EventArgs e)
{
aa = "update";
}
protected void GridView1_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
{
Label ll = (Label)GridView1.Rows[e.NewSelectedIndex].FindControl("Label1");
if (aa == "edit")
{
int a = ll.Text;
Label1.text = Color("Blue");
Label2.text = Color("Blue");


}
else
{
con.Open();
SqlCommand CC = new SqlCommand("delete from Bank_master where bank_pk = '" + ll.Text + "'", con);
SqlDataReader dr = CC.ExecuteReader();
GridView1.DataSource = dr;
GridView1.DataBind();
con.Close();
Response.Redirect("~/Admin/Bank_master_view.aspx");
}
}
 
Share this answer
 
Comments
Ace_Hardlight 13-Jul-11 7:23am    
uhm sorry but I don't get how this links to my question?
I never did WPF. In Windows Forms, DataGridViews have a boolean property with name FullRowSelect. If set to true, you always select the full row, not just a cell.

Maybe you could place a
<property value="true" />
somewhere?
 
Share this answer
 
v2
Comments
Ace_Hardlight 13-Jul-11 7:59am    
This does work to select the full row but my problem is the highlight of the row. Just the text gets hightlighted when i select a row and i want the full cell to be highlighted.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900