|
Is there any way to cause a DataGridView to lose focus? At the moment, the underlying dataset for a cell is not being updated until I lose focus. I either need to cause the data to be changed while still in focus, or cause the dataset to change focus and auto-save the data?
|
|
|
|
|
try giving focus to some other element at the time you want to lose focus from datagrid.
hope this helps....
- ashish
|
|
|
|
|
please send me the code for editing and updating data in a data grid.in C# ASP.net.
I have used the grid properties given in .net
|
|
|
|
|
I know how to read a text file line by line, open up a StreamReader and sr.ReadLine(), etc.
But is there an easy way to move through a string in memory line by line?
I thought i could "foreach" on the strings characters looking for the \n control character, etc. But its hardly as neat as ReadLine().
So is there a pre-build, neat way of reading an inmemory string line by line?
|
|
|
|
|
Yes.
System.IO.StringReader
---
b { font-weight: normal; }
|
|
|
|
|
The same way would work. Whether a file is persisted on disk or in memory it is what it is - that is, all the bytes are read in as-is unless transcoded (converted from one encoding to another) wile being read-in.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi,
Can anyone explain what I have been experienced here for radio button control?
I dropped three radio button into the form in Windows Application, it will recognize they are in the same group and allow me to check one radio button at a time.
I did the same in the Web application, it will let you check all the radio buttons at the same time.
Also, those nice valisation controls in Web tool box, not in Window at all?
It's bizzare that Microsoft handles their tool in this way.
Thanks
handy
|
|
|
|
|
You can't mix Windows Forms controls and Web Forms controls together like that (although a Winodws Forms control can be embedded into the resultant HTML to be displayed on the client - but not used on the server).
Windows Forms controls are tied to window handles that every control from the desktop and top-level windows to controls like radio buttons. These send messages throughout Windows.
Web Forms controls output HTML to the page to be displayed in the client. They are completely different things.
For Windows Forms, the radio buttons to be checked exlusively as a group must all be in the same container, be that an entire form or a GroupBox .
For Web Forms, the radio buttons must all have the same Name property (which is the name used in the form data).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Heath! It's been long time! Welcome back!
I've been missing your wisdom in the finer points of Win32!
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
It's been collecting at http://blogs.msdn.com/[^], though that's mostly about Windows Installer issues.
I do have an interop section where I post and explain the things I keep repeating here in order to keep from repeating them here!
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
HI,
i have the following problem.. i have the following string "abcd".
how to assign the "ab" to one string,
and "cd" to the other.
actually my input "ABCD" keep changing.. and they are in HEX.
i wanna assign then to 2 string.. one as the high byte then other as a low byte..
EXAMPLE.
input is HEX "ABCD"
i wanna assign High bit as "AB"
then lower as "CD"
then movw in total=low+high
end result is total = "CDBA"
thnak for your help guys
|
|
|
|
|
You could do a simple loop:
string input = "ABCD";
string output = string.Empty;
for (int i = input.Length - 2; i >= 0; i++)
{
output += input.Substring(i, 2);
} There's lots of ways you can do this, since it's simple string parsing. The fact that the input string is in hexadecimal is moot if you never need to convert it. Now, if you actually wanted to convert it to numbers you could do something like the following:
string input = "ABCD";
int high = int.Parse(input.Substring(0, 2), NumberStyles.AllowHexSpecifier);
int low = int.Parse(input.Substring(2, 2), NumberStyles.AllowHexSpecifier);
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Here's my issue in a nutshell. I have a table that I bind to columns in a DGV, and, in addition, I have one nonbound DataGridViewCheckBoxColumn in the [0] position. In my code, I bind the data, but upon trying to access the checkboxes, I get errors that say the values are null. How do I check the .Checked property of the checkboxes?
//relevant code, cut/pasted so it might be out of order.
//
// dataGridView1
//
this.dataGridView1.AllowUserToAddRows = false;
this.dataGridView1.AllowUserToDeleteRows = false;
this.dataGridView1.AllowUserToResizeColumns = false;
this.dataGridView1.AllowUserToResizeRows = false;
this.dataGridView1.AutoGenerateColumns = false;
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.dgvcbcSelect,
this.dgvtbcName,
this.dgvtbcDescription,
this.AttachmentKey,
this.AttachmentType,
this.AttachmentSourceID,
this.AttachmentID,
this.FileName,
this.FileSize,
this.ContentType});
this.dataGridView1.DataSource = this.attachmentBindingSource;
this.dataGridView1.Dock = System.Windows.Forms.DockStyle.Fill;
this.dataGridView1.Location = new System.Drawing.Point(0, 25);
this.dataGridView1.Name = "dataGridView1";
this.dataGridView1.Size = new System.Drawing.Size(792, 241);
this.dataGridView1.TabIndex = 1;
//
// dgvcbcSelect
//
this.dgvcbcSelect.HeaderText = "Select";
this.dgvcbcSelect.Name = "dgvcbcSelect";
this.dgvcbcSelect.Width = 50;
//
// dgvtbcName
//
this.dgvtbcName.DataPropertyName = "Name";
this.dgvtbcName.HeaderText = "Name";
this.dgvtbcName.Name = "dgvtbcName";
this.dgvtbcName.Width = 150;
//
// dgvtbcDescription
//
this.dgvtbcDescription.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.dgvtbcDescription.DataPropertyName = "Description";
this.dgvtbcDescription.HeaderText = "Description";
this.dgvtbcDescription.Name = "dgvtbcDescription";
// ALL OTHER COLUMNS HAVE .visible=false;
Anyways, when I load the form that has the datagrid, I do this:
{
InitializeComponent();
myAttachmentClient = new AttachmentClient(); //holder for the dataset
myAttachmentClient.LoadAttachmentList(inKey); //loads the data from a SQL server
versionKey = inKey;
dataGridView1.DataSource = myAttachmentClient.AttachmentTable;
}
After this, putting in MessageBox.Show(dataGridView1.Rows[0].Cells[0].Value.ToString()); gives me an error. How can I access the 'checked'-ness of the checkboxes?
|
|
|
|
|
Oohh, found my solution. Its MessageBox.Show(dataGridView1.Rows[0].Cells[0].FormattedValue.ToString()). Fuuuuun.
|
|
|
|
|
The current program I am working on has a lot of user Checkboxs and currently when ever I change a property I end up coding something like this:
CheckBox1->Enabled=true;
CheckBox2->Enabled=true;
...
CheckBox30->Enabled=true;
this is obviously not a very efficient way of doing this... so I'm looking for a more efficient way... maybe something along the lines of
for(int c=0;c!=31;c++)
{
CheckBox(c)->Enabled=true;
}
this code will obviously not work but any suggestions on how to make something like this work??? Cheers*
Debs
|
|
|
|
|
If all of your checkboxes are located in a container control (panel, groupbox) or if they are the only controls on your form then you could use a foreach statement.
foreach(Control aControl in form1.controls)
{
CheckBox aCheckBox = (CheckBox) aControl;
aCheckBox.Enabled = true;
}
I did not test the above code. It's just off the top of my head.
You could also create and arraylist of checkboxes and interate through then the same way.
www.lovethosetrains.com
-- modified at 13:10 Thursday 22nd September, 2005
|
|
|
|
|
You could put all CheckBoxes into an array and iterate over it:
CheckBox[] _allCheckBoxes;
_allCheckBoxes = new CheckBox[31];
_allCheckBoxes[0] = CheckBox1;
_allCheckBoxes[1] = CheckBox2;
foreach (CheckBox cb in _allCheckBoxes)
cb.Enabled = true;
|
|
|
|
|
Are you sure thats possible?
When I try to do it it wont work, it give's me A LOT of errors and all kinds of warnings.
Niklas Ulvinge aka IDK
|
|
|
|
|
Well...
yes Im sure .
If you want I can mail you a small sample.
|
|
|
|
|
Thanks for the suggestions I will try them out
Debs
|
|
|
|
|
Is it possible to do it with menuitems?
And sure, mail the sample to me...
My email is: ulvinge@gmail.com
Niklas Ulvinge aka IDK
|
|
|
|
|
Thanks for all the suggestions I managed to do do it by the following:
TCheckBox *ChkBx[34];
ChkBx[0]=CheckBox1; //Declaring them all once into an array
ChkBx[1]=CheckBox2;
...
ChkBx[33]=CheckBox33;
for(int i=0;i!=4;i++)
{
ChkBx[i]->Checked=true;
}
I also used this concept with Graph Line Series ie.
TChartSeries *Ser[4];
...
Thanks Again
Debs
-- modified at 13:11 Friday 23rd September, 2005
|
|
|
|
|
Hello!
Ihave extendended the ShellLib (from arikp's article) to support the IEnumIDList interface. Here is the code:
<br />
[ComImport]<br />
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]<br />
[Guid("000214F2-0000-0000-C000-000000000046")]<br />
public interface IEnumIDList<br />
{<br />
[PreserveSig]<br />
Int32 Clone(out IntPtr ppenum);<br />
<br />
[PreserveSig]<br />
Int32 Next(UInt32 celt, <br />
[MarshalAs(UnmanagedType.LPArray, SizeParamIndex=0)]<br />
out IntPtr[] rgelt,<br />
out UInt32 pceltFetched<br />
);<br />
<br />
[PreserveSig]<br />
Int32 Reset();<br />
<br />
[PreserveSig]<br />
Int32 Skip(UInt32 celt);<br />
}<br />
and I get an instance of this interface using:
<br />
public static IEnumIDList GetEnumIDList(IntPtr ptrEnumIDList)<br />
{<br />
System.Type shellEnumIDListType = System.Type.GetType("ShellLib.IEnumIDList");<br />
Object obj = Marshal.GetTypedObjectForIUnknown(ptrEnumIDList, shellEnumIDListType);<br />
IEnumIDList RetVal = (IEnumIDList)obj;<br />
return RetVal;<br />
}<br />
If I try this code:
<br />
UInt32 celt = 10;<br />
IntPtr[] ptrList = new IntPtr[celt];<br />
UInt32 count;<br />
EnumIDList.Next(celt, out ptrList, out count)<br />
The Shell dosen't fill the ptrList and count is 0. The IShellFolder is the Desktop folder.
<br />
IntPtr ptrFoldersList;<br />
iDesktopFolder.EnumObjects(this.Handle, (Int32)ShellApi.SHCONTF.SHCONTF_FOLDERS | (Int32)ShellApi.SHCONTF.SHCONTF_STORAGE, out ptrFoldersList);<br />
If you need any details please let me know. I don't really see what I did wrong... (maybe I'm dumb ).
Thank you!
|
|
|
|
|
When deriving your interface from IUnknown (which is what happens in the CLR when you specify ComInterfaceType.InterfaceIsIUnknown for the InterfaceTypeAttribute on the interface), the methods must be in the ordered defined - not the order documented. This means the interface should be defined as:
[Guid("000214F2-0000-0000-C000-000000000046"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown),
ComImport]
public interface IEnumIDList
{
[PreserveSig] int Next(ulong celt, IntPtr[] rgelt, out ulong pceltFetched);
[PreserveSig] int Skip(ulong celt);
[PreserveSig] int Reset();
[PreserveSig] int Clone(out IEnumIDList ppenum);
} This is also true of ComInterfaceType.InterfaceIsDual . If you use only ComInterfaceType.InterfaceIsIDispatch then you must have attribute your methods and properties with the correct DispIdAttribute values.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
It works now! Thank you very much. I'll keep that in mind next time.
|
|
|
|