编辑
我找到并发布了解决方案.
我正在尝试为我的应用程序创建一个安装程序,我正在尝试使用面板(我不知道这是否是一个很好的方法,但这给了我更多的自定义选项,而不是使用安装盾程序) .最好的方法是什么?
这是我知道的代码:
C#代码
foreach (Control c in Controls)
{
if (c is Panel)
{
if (c.Name != "pnlBottom")
{
if (c.Name.Contains(_currentPanel.ToString()))
{
c.Visible = true;
return;
}
else
{
c.Visible = false;
}
}
}
}
Run Code Online (Sandbox Code Playgroud) 我想防止在带有滚动条的面板中使用鼠标滚轮滚动,如何做到这一点?
我已经看到这个建议,但它不起作用:
panel.MouseWheel += new MouseEventHandler(MouseWheel);
void MouseWheel(object sender, MouseEventArgs e) {
((HandledMouseEventArgs)e).Handled = true;
}
Run Code Online (Sandbox Code Playgroud) 我正在制作一个带有摆动的图形程序,其中包括在框架上放置带有组件的各种面板。One of them is a panel with buttons that, when an option in an options menu is chosen, is entirely replaced with a different one that has different buttons. 我们一直在思考,似乎最好的方法是,每次选择该选项时,从头开始重建框架。
这是我构建主面板的代码片段:
import java.awt.Color;
import java.awt.Dimension;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.border.EmptyBorder;
import com.jtattoo.plaf.graphite.GraphiteLookAndFeel;
import com.nacher.calc.Main;
import com.nacher.calc.controller.Controller;
import net.miginfocom.swing.MigLayout;
/**
*
* @author chema && Sergio
* This Panel contains buttons and textbox to perform the calculator actions
*/
public class PanelCalculator …Run Code Online (Sandbox Code Playgroud) 我正在尝试将管理员重定向到管理面板页面,将用户重定向到主页
我为用户类型创建了新字段,并在数据库中添加了“admin”值
$table->string('usertype')->nullable();
Run Code Online (Sandbox Code Playgroud)
然后我创建了这个中间件(AdminMiddleware):
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class AdminMiddleware
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle(Request $request, Closure $next)
{
if(Auth::user()->usertype == 'admin')
{
return $next($request);
}
else
{
return redirect('/dashboard');
}
}
}
Run Code Online (Sandbox Code Playgroud)
然后我将它添加到内核中:
'admin' => \App\Http\Middleware\AdminMiddleware::class,
Run Code Online (Sandbox Code Playgroud)
我将该函数添加到 RouteServiceProvider 并导入该类:
public const HOME = '/dashboard';
protected function redirectTo()
{
if(Auth::user()->usertype == 'admin')
{
return 'panel';
}
else …Run Code Online (Sandbox Code Playgroud) 我有一个 TScrollBox,里面有一堆 TPanel,还有一些在运行时生成的 TButton。我需要在单击一个 TButton 时删除 TPanel,但在 OnClick 中执行此操作会导致访问冲突......
procedure TMainForm.ButanClick(Sender: TObject);
var
vParentPanel: TPanel;
begin
if (string(TButton(Sender).Name).StartsWith('L')) then
begin
TButton(Sender).Caption := 'YARE YARE DAZE';
end
else
begin
vParentPanel := TPanel(TButton(Sender).GetParentComponent());
TheScrollBox.RemoveComponent(vParentPanel);
vParentPanel.Destroy();
// access violation but the panel is removed
end;
end;
procedure TMainForm.Button3Click(Sender: TObject);
var
i: Integer;
vPanel: TPanel;
vButton: TButton;
begin
for i := 0 to 20 do
begin
vPanel := TPanel.Create(TheScrollBox);
vPanel.Align := alTop;
vPanel.Parent := TheScrollBox;
vButton := TButton.Create(vPanel);
vButton.Align := alLeft;
vButton.Parent := vPanel; …Run Code Online (Sandbox Code Playgroud) 我在堆栈溢出中搜索了类似“如何更改面板边框颜色 vb.net”的内容,但没有找到任何结果,所以我删除了 vb.net 并像这样输入,我找到了结果,但它仅适用于 C#,我不这样做C# 好多了,也许我认为我可以翻译,但我只是认为翻译不会100% 准确,所以,这就是我提出这个问题的原因。请帮助我如何更改VB.Net中面板的边框颜色我已在属性中设置了 BorderStyle FixSingle,但仍然无法更改面板的边框颜色。请帮助并告诉我如何更改面板的边框颜色,否则我们无法从属性中做到这一点,我们可以通过编码来做到这一点,那么至少请给我代码。
我想在视觉工作室的一个表格(图片框)中自由地绘制并在另一个面板/图片框上复制相同的图形(我绘制).它们也不应该是形成一条线而是一条连续线的点.请帮忙.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
Pen p_white;
bool draw = true;
private Graphics objgraphics;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
}
private void panel1_Paint(object sender, PaintEventArgs e)
{
Pen p_black = new Pen(new SolidBrush(Color.Black));
if (draw)
{
objgraphics = panel1.CreateGraphics();
}
}
/*private void panel1_MouseDown(object sender, MouseEventArgs e)
{
bool …Run Code Online (Sandbox Code Playgroud)