|
I have two dictionaries that I output to two separate DataGridViews. I need to be able to alternate the output of the two dictionaries to one DataGridView. Any help would be appreciated.
|
|
|
|
|
Then just do so by writing some code.
The two dictionaries better have the same number of entries, otherwise you'd have to come up with a more precise specification.
BTW: Right now I can't imagine an application domain where your requirement makes sense.
Luc Pattyn
Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
I am differencing two files. Each file's specs are put into a dictionary and then output the two files into two separate DataGridViews. Then differences are colored. I am required to show these in a single DataGridView where one line of the gridview is outputted from one dictionary and then the other dictionary is outputted as they alternate. The dictionaries can have different amout of entries as one file may have more or less records than the other.
|
|
|
|
|
I was just trying to give file premission to my dummy files but encountered a problem. I found out that only the last applied permission is imposed on the file while rest are overriden or not applied.
using System;
using System.IO;
public class RegistryEditor
{
public static void Main()
{
try
{
FileInfo f = new FileInfo(@"C:\Test.txt");
f.Attributes = FileAttributes.System;
FileInfo f1 = new FileInfo(@"C:\Test.txt");
f1.Attributes = FileAttributes.ReadOnly;
FileInfo f2 = new FileInfo(@"C:\Test.txt");
f2.Attributes = FileAttributes.Hidden;
FileInfo i = new FileInfo(@"C:\Test1.txt");
i.Attributes = FileAttributes.System;
i.Attributes = FileAttributes.Hidden;
i.Attributes = FileAttributes.ReadOnly;
}
catch (Exception ex)
{
Console.Write(ex.ToString());
}
}
}
Banking establishments are more dangerous then standing armies.
|
|
|
|
|
Hi,
int i;
i=1;
i=2;
i=4;
Now what is the final value of i? Is it 7? Why would it be any different with file attributes?
File attributes are flags, i.e. they have a binary pattern with one bit set, all others cleared. So you can OR them together (with the '|' operator) to get combinations of them.
Luc Pattyn
Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
You are going to kick yourself! You are, you are...
Ishaan Karnik wrote:
FileInfo f = new FileInfo(@"C:\Test.txt");
f.Attributes = FileAttributes.System;
Assume it works: the attributes for the file are now "System"
Ishaan Karnik wrote:
FileInfo f1 = new FileInfo(@"C:\Test.txt");
f1.Attributes = FileAttributes.ReadOnly;
Assume it works: the attributes for the file are now "ReadOnly"
Had you considered?
FileInfo f1 = new FileInfo(@"C:\Test.txt");
f1.Attributes += FileAttributes.ReadOnly;
What are the attributes now?
I told you, you would kick yourself!
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
Except that if it already was ReadOnly, it will be Hidden and not ReadOnly anymore. (ReadOnly = 1, Hidden = 2)
|
|
|
|
|
Yes you are right, I'll start kicking myself when I stop typing: it should be "|=" not "+="
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
OriginalGriff,
Yes, i had considered
FileInfo i = new FileInfo(@"C:\Test.txt");<br />
i.Attributes += FileAttributes.ReadOnly;<br />
But this gives an error Operator ' += ' cannot be applied to operands of type 'System.IO.FileAttributes' and 'System.IO.FileAttributes'.
Luc Pattyn,
ThankYou. Your suggestion worked.
|
|
|
|
|
you're welcome.
Luc Pattyn
Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
Hi
i'm looking for a calendar control like outlook 2007.
can anybody help me ?
thanks
|
|
|
|
|
If you had, at the very least, searched the CP articles, you might have found MS Outlook style Calendar[^].
You didn't search, so you didn't find. Think yourself lucky that I'm in a good mood today, for a change!
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hello, you can try this one:
<input onclick="showcalendar(event, this)" onfocus="showcalendar(event, this)" size=24 name=birthday>
JS code:
var userAgent = navigator.userAgent.toLowerCase();
var is_webtv = userAgent.indexOf('webtv') != -1;
var is_saf = userAgent.indexOf('applewebkit') != -1 || navigator.vendor == 'Apple Computer, Inc.';
var is_opera = userAgent.indexOf('opera') != -1 && opera.version();
var is_moz = (navigator.product == 'Gecko' && !is_saf) && userAgent.substr(userAgent.indexOf('firefox') + 8, 3);
var is_ie = (userAgent.indexOf('msie') != -1 && !is_opera && !is_saf && !is_webtv) && userAgent.substr(userAgent.indexOf('msie') + 5, 3);
var controlid = null;
var currdate = null;
var startdate = null;
var enddate = null;
var yy = null;
var mm = null;
var currday = null;
var addtime = false;
var today = new Date();
var lastcheckedyear = false;
var lastcheckedmonth = false;
function $(id) {
return document.getElementById(id);
}
function doane(event) {
e = event ? event : window.event ;
if(is_ie) {
e.returnValue = false;
e.cancelBubble = true;
} else {
e.stopPropagation();
e.preventDefault();
}
}
function loadcalendar() {
s = '<style type="text/css">';
s += '.calendar_header {text-align: center;BORDER: #698CC3 1px solid; BACKGROUND: white; outline: 1px solid #698CC3}';
s += '.calendar_checked A { COLOR: #FFF; background:#698CC3;}';
s += '.calendar_expire A:link { COLOR: #999;}';
s += '.calendar_default A:link { COLOR: #000;}';
s += '.calendar_today A:link { display: inline-block;COLOR: #9EB6D8; border:1px solid #698CC3; padding:1px;}';
s += '.calendar_expire A:hover,.calendar_today A:hover,.calendar_default A:hover { COLOR: #FFF; background:#9EB6D8;}';
s += '#calendar_year,#calendar_month { Z-INDEX: 10; DISPLAY: none; POSITION: absolute;}';
s += '</style>';
s += '<div id="calendar" style="display:none; position:absolute; z-index:9;" onclick="doane(event)">';
s += '<div style="width: 180px;"><table cellspacing="0" cellpadding="0" width="100%" style="text-align: center;BORDER: #698CC3 1px solid; BACKGROUND: white; outline: 1px solid #698CC3">';
s += '<tr align="center" bgcolor="#E3EFFF"><td height=20><a onclick="refreshcalendar(yy, mm-1)" title="上一月"><<</a></td>';
s += '<td colspan="5" style="text-align: center"><a onclick="showdiv(\'year\');doane(event)" title="点击选择年份"><span id="year"></span>年</a> ';
s += '<a onclick="showdiv(\'month\');doane(event)" title="点击选择月份"><span id="month"></span>月</a></td><td><A onclick="refreshcalendar(yy, mm+1)" title="下一月">>></A></td></tr>';
s += '<tr><td height=20>日</td><td>一</td><td>二</td>& lt;td>三</td><td>四</td><td>五< /td><td>六</td></tr>';
s += '<tr><td colspan="7" height="1"><hr width="100%" size="1" /></td></tr>';
for(var i = 0; i < 6; i++) {
s += '<tr>';
for(var j = 1; j <= 7; j++)
s += '<td id=d' + (i * 7 + j) + ' height="19"></td>';
s += "</tr>";
}
s += '</table></div></div>';
s += '<div id="calendar_year" onclick="doane(event)">';
s += '<select id=calendar_year_select size=10 onchange="refreshcalendar(this.options[this.selectedIndex].value,mm);$(\'calendar_year\').style.display=\'none\';">'
for(var k = today.getFullYear()-100; k <= today.getFullYear()+100; k++) {
s += '<option value='+ k +'>'+ k +'</option>';
}
s += '</select>';
s += '</div>';
s += '<div id="calendar_month" onclick="doane(event)" style="height:210px;OVERFLOW:auto;padding-left:5px">';
s += '<select id=calendar_month_select size=10 onchange="refreshcalendar(yy,this.options[this.selectedIndex].value-1);$(\'calendar_month\').style.display=\'none\';">'
for(var k = 1; k <= 12; k++) {
s += '<option value=' + (k<10? '0' : '') + k +'>' + (k<10? '0' : '') + k +'</option>';
}
s += '</select>';
s += '</div>';
if(is_ie && is_ie < 7) {
s += '<iframe id="calendariframe" frameborder="0" style="display:none;position:absolute;filter:progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)"></iframe>';
s += '<iframe id="calendariframe_year" frameborder="0" style="display:none;position:absolute;filter:progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)"></iframe>';
s += '<iframe id="calendariframe_month" frameborder="0" style="display:none;position:absolute;filter:progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)"></iframe>';
}
document.write(s);
document.onclick = function(event) {
$('calendar').style.display = 'none';
$('calendar_year').style.display = 'none';
$('calendar_month').style.display = 'none';
if(is_ie && is_ie < 7) {
$('calendariframe').style.display = 'none';
$('calendariframe_year').style.display = 'none';
$('calendariframe_month').style.display = 'none';
}
}
$('calendar').onclick = function(event) {
doane(event);
$('calendar_year').style.display = 'none';
$('calendar_month').style.display = 'none';
if(is_ie && is_ie < 7) {
$('calendariframe_year').style.display = 'none';
$('calendariframe_month').style.display = 'none';
}
}
}
function parsedate(s) {
/(\d+)\-(\d+)\-(\d+)\s*/.exec(s);
var m1 = (RegExp.$1 && RegExp.$1 > today.getFullYear()-120 && RegExp.$1 < today.getFullYear()) ? parseFloat(RegExp.$1) : today.getFullYear();
var m2 = (RegExp.$2 && (RegExp.$2 > 0 && RegExp.$2 < 13)) ? parseFloat(RegExp.$2) : today.getMonth() + 1;
var m3 = (RegExp.$3 && (RegExp.$3 > 0 && RegExp.$3 < 32)) ? parseFloat(RegExp.$3) : today.getDate();
/(\d+)\-(\d+)\-(\d+)\s*(\d*):?(\d*)/.exec("0000-00-00");
return new Date(m1, m2 - 1, m3);
}
function settime(d) {
yy = yy;
mm = mm;
$('calendar').style.display = 'none';
$('calendar_month').style.display = 'none';
if(is_ie && is_ie < 7) {
$('calendariframe').style.display = 'none';
}
controlid.value = yy + "-" + zerofill(mm + 1) + "-" + zerofill(d);
}
function showcalendar(event, controlid1, addtime1, startdate1, enddate1) {
controlid = controlid1;
addtime = addtime1;
startdate = startdate1 ? parsedate(startdate1) : false;
enddate = enddate1 ? parsedate(enddate1) : false;
currday = controlid.value ? parsedate(controlid.value) : today;
yy = currday.getFullYear();
mm = currday.getMonth();
$('calendar').style.display = 'block';
$('calendar').style.left = ie_x(controlid)+'px';
$('calendar').style.top = (ie_y(controlid) + 16)+'px';
doane(event);
refreshcalendar(currday.getFullYear(), currday.getMonth());
lastcheckedyear = currday.getFullYear();
lastcheckedmonth = currday.getMonth() + 1;
if(is_ie && is_ie < 7) {
$('calendariframe').style.top = $('calendar').style.top;
$('calendariframe').style.left = $('calendar').style.left;
$('calendariframe').style.width = $('calendar').offsetWidth;
$('calendariframe').style.height = $('calendar').offsetHeight;
$('calendariframe').style.display = 'block';
}
}
function refreshcalendar(y, m) {
var x = new Date(y, m, 1);
var mv = x.getDay();
var d = x.getDate();
var dd = null;
yy = x.getFullYear();
mm = x.getMonth();
$("year").innerHTML = yy;
$("month").innerHTML = mm + 1 > 9 ? (mm + 1) : '0' + (mm + 1);
$("calendar_year_select").value = yy;
$("calendar_month_select").value= mm + 1 > 9 ? (mm + 1) : '0' + (mm + 1);
for(var i = 1; i <= mv; i++) {
dd = $("d" + i);
dd.innerHTML = " ";
dd.className = "";
}
while(x.getMonth() == mm) {
dd = $("d" + (d + mv));
dd.innerHTML = '<a href="#" onclick="settime(' + d + ');return false">' + d + '</a>';
if(x.getTime() < today.getTime() || (enddate && x.getTime() > enddate.getTime()) || (startdate && x.getTime() < startdate.getTime())) {
dd.className = 'calendar_expire';
} else {
dd.className = 'calendar_default';
}
if(x.getFullYear() == today.getFullYear() && x.getMonth() == today.getMonth() && x.getDate() == today.getDate()) {
dd.className = 'calendar_today';
dd.firstChild.title = '今天';
}
if(x.getFullYear() == currday.getFullYear() && x.getMonth() == currday.getMonth() && x.getDate() == currday.getDate()) {
dd.className = 'calendar_checked';
}
x.setDate(++d);
}
while(d + mv <= 42) {
dd = $("d" + (d + mv));
dd.innerHTML = " ";
d++;
}
}
function showdiv(id) {
$('calendar_' + id).style.left = ie_x($(id))+'px';
$('calendar_' + id).style.top = (ie_y($(id)) + 16)+'px';
$('calendar_' + id).style.display = 'block';
if(is_ie && is_ie < 7) {
$('calendariframe_' + id).style.top = $('calendar_' + id).style.top;
$('calendariframe_' + id).style.left = $('calendar_' + id).style.left;
$('calendariframe_' + id).style.width = $('calendar_' + id).offsetWidth;
$('calendariframe_' + id ).style.height = $('calendar_' + id).offsetHeight;
$('calendariframe_' + id).style.display = 'block';
}
}
function zerofill(s) {
var s = parseFloat(s.toString().replace(/(^[\s0]+)|(\s+$)/g, ''));
s = isNaN(s) ? 0 : s;
return (s < 10 ? '0' : '') + s.toString();
}
loadcalendar();
April
Comm100 - Leading Live Chat Software Provider
modified 27-May-14 22:02pm.
|
|
|
|
|
I am trying a program to add keys, however i am getting an exception saying
System.UnauthorizedAccessException : Cannot write to registry key
You can consider me beginner in registry editing issue.
using System;
using System.Security.Permissions ;
using Microsoft.Win32;
public class RegistryEditor
{
public static void Main()
{
try
{
RegistryKey hkcu = Registry.CurrentUser;
RegistryKey hkSoftware = hkcu.OpenSubKey("Software");
RegistryKey hkMicrosoft = hkSoftware.OpenSubKey("Microsoft");
RegistryKey hkIshaan = hkSoftware.CreateSubKey("Test1");
hkIshaan.SetValue("Name", "Ishaan");
hkIshaan.SetValue("Age", "20");
hkIshaan.Close();
hkSoftware.Close();
hkcu.Close();
}
catch (Exception ex)
{
Console.Write(ex.ToString());
}
}
}
Banking establishment are more dangerous then standing armies.
|
|
|
|
|
Two things:
1) You can concatenate your two OpenSubKey calls:
RegistryKey hkMicrosoft = hkcu.OpenSubKey(@"Software\Microsoft");
2) The OpenSubkey has 4 overloads. If you look it up on MSDN the last one allows you to specify the RegistryKeyPermissionCheck (what you can do with subkeys), and RegistryRights (read only, read/write TakeOwnership etc.).
I am still on XP, so I don't know how this applies under Vista and Weven, which I know are a bit more picky about these sorts of things.
Hope that this is of some help!
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Thank You . I am also using XP. Is my rest of the code right?
|
|
|
|
|
The only thing that I would say is, don't use the Microsoft subkey for writing to. Create your own subkey under Software for messing about with IshaanTesting or something like that.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hi everyOne.
I have dataGridView in my project whitch is Bind to my dataBase
(Student's Table).After 3 months that the user has Saved around 3,000 rows in that table Now when they open that form with 3,000 Rows in Student's table it takes along time to load the form(Form become white).
What should i do to run that form without any problem and Quickly?
Thank u.
CanI
|
|
|
|
|
You need to filter what is retrieved and or displayed.
To filter what is retrieved, put a WHERE clause in the SELECT statement, to limit it to students whose name begins with 'A', for example. then allow the users to hit a 'Next' or 'Previous' button to move from the 'A's to the 'B's and vice versa. Or by their Major, or whatever.
To Filter what is displayed, the BindingSource has a Filter property that you can use to get a similar effect.
Hope this helps!
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
how to use update progress bar while loading a panel on clicking the save button the save button exists in the other panel
|
|
|
|
|
This is such a common question that I am going to recommend that you search the CP messages, using the Search box at the top of the page. Or Bingle for it.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
hi guys,
i use in my form a checkedlistbox ...my problem is that when i write this code this.checkedListBox1.SelectionMode = SelectionMode.One; i would expect only one checkbox to be checked every time.But in my case i can select all the checkboxes so something is wrong..
thanks in advance..
|
|
|
|
|
I guess that the CheckedListBox can only have one selected item (meaning that only one row has highlighted atta time)
That doesn't limit the number of check's that the user can set. Checkboxes aren't mutually exclusive, they "hint" that the user can check multiple items. If you want a mutual exclusive selection, try changing to a RadioButton[^].
The radiobutton allows the user to select 1 item from the list of options.
I are Troll
|
|
|
|
|
I haven't checked this out, since I don't have VS on this machine, but SelectionMode usually refers to the Items in the ListBox not the CheckBoxes .
I do not know of any simple way to restrict how many items are checked. You can periodically check on the CheckedItems collection and uncheck any except for the one you want, but what event you would use to trigger this checking, I do not know.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hi,
Confusingly the SelectionMode does not refer the number of items that may be checked but the desired effect is possible through the ItemChecked event.
The new item is checked only after the handler returns and so single selection can be achieved by simply removing all existing checks.
private void CheckedListBox_ItemCheck(object sender, ItemCheckEventArgs e) {
if (e.NewValue == CheckState.Checked) {
CheckedListBox clb = sender as CheckedListBox;
if (clb != null) {
foreach (Int32 index in clb.CheckedIndices) {
clb.SetItemCheckState(index, CheckState.Unchecked);
}
}
}
}
Alan.
|
|
|
|