问题描述
我正在尝试使用C#在图表中使用滚动条。使用下一个代码,我可以看到滚动条,但是当图表第一次显示数据时,我会从非常旧的日期中获取数据(该数据在我的数据集中不存在),并且当我使用滚动条的按钮在图表上移动我可以在绘图区域中看到两天的正确数据,并且可以使用向左和向右按钮移动。当我按下滚动条上的重置按钮时,图表将显示表中的所有数据,但滚动条会消失,我需要查看它。现在,我正在尝试解决我的问题,这些问题是:首次绘制图表时显示正确的数据,使用向左和向右按钮配置x轴窗口的限制,并在按下重置按钮后继续显示滚动条。我希望你能给我一个提示。
try
{
var domainName = System.Net.networkinformation.IPGlobalProperties.GetIPGlobalProperties().DomainName;
MessageBox.Show(domainName);
using (var context = new PrincipalContext(ContextType.Domain,domainName))
{
using (var searcher = new PrincipalSearcher(new UserPrincipal(context)))
{
foreach (var result in searcher.FindAll())
{
ListViewItem tmpItem = null;
DirectoryEntry child = result.GetUnderlyingObject() as DirectoryEntry;
switch (child.SchemaClassName)
{
case "user":
int flag = (int)child.Properties["userAccountControl"].Value;
bool disabled = Convert.ToBoolean(flag & 0x0002);
if (disabled == false)
{
tmpItem = new ListViewItem(new string[] {
(string)child.Properties["givenname"].Value,(string)child.Properties["sn"].Value,(string)child.Properties["samAccountName"].Value
},(int)AdImages.User);
this.listView_ad.Items.Add(tmpItem);
}
else
{
tmpItem = new ListViewItem(new string[] {
(string)child.Properties["givenname"].Value,(int)AdImages.block);
this.listView_ad.Items.Add(tmpItem);
}
break;
case "organizationalUnit":
break;
case "container":
break;
case "computer":
break;
case "group":
break;
default:
break;
}
}
}
}
}
catch (Exception e)
{
MessageBox.Show("ERROR : " + e,"Error",MessageBoxButtons.OK,MessageBoxIcon.Warning);
}
************** Exception Text **************
System.NullReferenceException: Object reference not set to an instance of an object.
at ComputeamPasswordManager.PasswordManager.getUsers()
at ComputeamPasswordManager.PasswordManager.PasswordManager_Load(Object sender,EventArgs e)
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fignoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd,Int32 msg,IntPtr wparam,IntPtr lparam)
下图显示了按下右键时的图表
下图显示按下复位按钮时的图表
我只想在此图表上放置一个滚动条并以此来控制绘图区域,但是这对我来说非常困难。我希望你能给我一个线索。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)