如何修改 FlowLayoutPanel 中动态添加的元素?
我创建标签并将其添加到面板中。
`for (int i=0; i<10; i++)
{
Label nlabel = new Label();
nlabel.text = "Label no."+i.toString();
nlabel.name = "label"+i.toString();
flowLayoutPanel1.Controls.Add(nlabel);.
}`
Run Code Online (Sandbox Code Playgroud)
创建并添加后,我想引用元素“i”。该面板没有方法 FlowLayoutPanel.getItem(int index);(
怎么做?
谢谢你的回答。
我想创建具有通用功能的共享库(插件)。 T可以是:u8、u16、u32、float、i8、i16、i32。
pub struct Api {}
impl Api {
pub fn write_to_slave<T>(&self, id: u32, value: T)
{
println!("write to slave id : {}, value: {}", id, value);
}
}
Run Code Online (Sandbox Code Playgroud)
错误:
|
18 | pub fn write_to_slave<T>(&self, id: u32, value: T)
| - help: consider restricting this bound: `T: std::fmt::Display`
19 | {
20 | println!("write to slave id : {}, value: {}", id, value);
| ^^^^^ `T` cannot be formatted with the default formatter
|
= help: the trait …Run Code Online (Sandbox Code Playgroud)