使用react,我点击第一个输入来显示第二个输入(react-ace编辑器),如何使第二个输入(react-ace编辑器)自动获得焦点并且第一个输入失去焦点?
private void button3_Click(object sender, EventArgs e)
{
System.Data.OleDb.OleDbConnection ExcelConnection = new System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Users\\Excel\\Desktop\\Coding\\DOT.NET\\Samples C#\\Export DataGridView to SQL Server Table\\Import_List.xls;Extended Properties=Excel 8.0;");
ExcelConnection.Open();
string expr = "SELECT * FROM [Sheet1$]";
OleDbCommand objCmdSelect = new OleDbCommand(expr, ExcelConnection);
OleDbDataReader objDR = null;
SqlConnection SQLconn = new SqlConnection();
string ConnString = "Data Source=Excel-PC;Initial Catalog=Northwind.MDF;Trusted_Connection=True;";
SQLconn.ConnectionString = ConnString;
SQLconn.Open();
using (SqlBulkCopy bulkCopy = new SqlBulkCopy(SQLconn))
{
bulkCopy.DestinationTableName = "tblTest";
try
{
objDR = objCmdSelect.ExecuteReader();
bulkCopy.WriteToServer(objDR);
ExcelConnection.Close();
//objDR.Close()
SQLconn.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
}
答案 0 :(得分:0)
将focus={true}
传递给AceEditor,在点击input
之前不要渲染它。呈现AceEditor
后,它会聚焦,从而导致input
模糊。
经过测试并且有效。
<input onClick={() => this.setState({ show: true })}/>
{
this.state.show &&
<AceEditor
focus
mode="javascript"
theme="monokai"
onChange={(newValue) => this.code=newValue}
name="UNIQUE_ID_OF_DIV"
editorProps={{$blockScrolling: true}}
/>
}