[go: up one dir, main page]

0% found this document useful (0 votes)
29 views3 pages

Private Void Object: "Name"

This code handles searching and selecting a row in a datagrid. When the search button is clicked, it gets the selected row from the datagrid and sets the text of the search name text box to a value from that row. It then gets the ID value from the selected cell and shows it in a message box. There is also commented out code for searching by ID that loops through the datagrid rows to find the one with a matching ID value.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views3 pages

Private Void Object: "Name"

This code handles searching and selecting a row in a datagrid. When the search button is clicked, it gets the selected row from the datagrid and sets the text of the search name text box to a value from that row. It then gets the ID value from the selected cell and shows it in a message box. There is also commented out code for searching by ID that loops through the datagrid rows to find the one with a matching ID value.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 3

private void SrchBtn_Click(object sender, RoutedEventArgs e)

DataGrid drg = (DataGrid)sender;

DataRowView row_seletceditem = drg.SelectedItem as DataRowView;

if(row_seletceditem != null)

srchName.Text = row_seletceditem["Name"].ToString();

// Empinfo emp = (Empinfo)gridtest.SelectedItems;

object item = srchName.Text;

string id = (gridtest.SelectedCells[0].Column.GetCellContent(item) as
TextBlock).Text;

MessageBox.Show(id);

//string id =
((DataRowView)gridtest.SelectedItem).Row["Id"].ToString();

/* int itemrow = -1;

string searchvalue = srchName.Text.ToUpper();

if(searchvalue!=null && searchvalue!="")

//foreach(DataGrid row in gridtest.)

int idTofind = Convert.ToInt32(srchID.Text);

if(idTofind<1 && gridtest.ItemsSource is DataView)

foreach(DataRowView drv in (DataView) gridtest.ItemsSource)

if ((int)drv["Id"] == idTofind)

gridtest.SelectedItem = drv;
}

}*/

/*private void srchname_textchanged(object sender, TextChangedEventArgs e)

FindNameSearch(srchName.Text);

public void FindNameSearch(DependencyObject obj)

for (int i = 0; i < VisualTreeHelper.GetChildrenCount(obj); i++)

ListViewItem lv = obj as ListViewItem;

if (lv != null)

HighlightText(lv);

FindNameSearch(VisualTreeHelper.GetChild(obj as DependencyObject,
i));

private void HighlightText(object itx)

if (itx != null)
{

if (itx is TextBlock)

else

return;

*/

You might also like