|
|
@ -32,12 +32,6 @@ namespace DyeingComputer.View |
|
|
|
{ |
|
|
|
InitializeComponent(); |
|
|
|
set_sql(); |
|
|
|
|
|
|
|
|
|
|
|
//Grid.Focus();
|
|
|
|
Grid.SelectedIndex = 0; |
|
|
|
// var row = Grid.ItemContainerGenerator.ContainerFromIndex(0) as FrameworkElement;
|
|
|
|
//if (row != null ) {row.Focus(); }
|
|
|
|
} |
|
|
|
|
|
|
|
private SQLiteHelper SQLiteHelpers = null; //定义数据库
|
|
|
@ -65,16 +59,44 @@ namespace DyeingComputer.View |
|
|
|
|
|
|
|
int rownum = Grid.SelectedIndex;//获取鼠标选中行并定义变量
|
|
|
|
if (rownum != -1)//判断鼠标定位是否有效
|
|
|
|
{ |
|
|
|
{ |
|
|
|
ID = (Grid.Columns[1].GetCellContent(Grid.Items[rownum]) as TextBlock).Text;//定位第0列,
|
|
|
|
|
|
|
|
Dictionary<string, object> datagrid_v = new Dictionary<string, object>();//缓存函数
|
|
|
|
datagrid_v.Add("Value", newValue); |
|
|
|
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
|
|
|
SQLiteHelpers.Open(); //打开数据库
|
|
|
|
SQLiteHelpers.Update("Parameters",datagrid_v , "ParameterID ='"+ ID + "'", null);//更新
|
|
|
|
SQLiteHelpers.Update("Parameters", datagrid_v, "ParameterID ='" + ID + "'", null);//更新
|
|
|
|
SQLiteHelpers.Close();//关闭数据库
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void UserControl_Loaded(object sender, RoutedEventArgs e)//打开页面时的操作
|
|
|
|
{ |
|
|
|
DataGridRow dr = (DataGridRow)Grid.ItemContainerGenerator.ContainerFromIndex(0);//取第0行单元格
|
|
|
|
DataGridCellsPresenter presenter = GetVisualChild<DataGridCellsPresenter>(dr); |
|
|
|
DataGridCell cell = (DataGridCell)presenter.ItemContainerGenerator.ContainerFromIndex(3); //取第3列每行单元格
|
|
|
|
cell.Focus(); |
|
|
|
Grid.SelectedIndex = 0; |
|
|
|
} |
|
|
|
public static T GetVisualChild<T>(Visual parent) where T : Visual |
|
|
|
{ |
|
|
|
T child = default(T); |
|
|
|
int numVisuals = VisualTreeHelper.GetChildrenCount(parent); |
|
|
|
for (int i = 0; i < numVisuals; i++) |
|
|
|
{ |
|
|
|
Visual v = (Visual)VisualTreeHelper.GetChild(parent, i); |
|
|
|
child = v as T; |
|
|
|
if (child == null) |
|
|
|
{ |
|
|
|
child = GetVisualChild<T>(v); |
|
|
|
} |
|
|
|
if (child != null) |
|
|
|
{ |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
return child; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|