|
|
Hi,
First time I am using datagridview I have some questions and problems.
Please guide me or provide solutions if possible.
I am using adapter to bind the DGV.
1. My datasource is coming through multiple tables
Exe: select a,b,c,d from t1 left outer join t2 on t1.a=t2.d
Because of that any kind of modification update, delete, insert not working
2. unable to add auto row columns
3. unable to find cells textbox property, I want to use cells textbox autocomplete property for providing help to users
<pre> private void dgCountryZone_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
if (dgCountryZone.Columns[this.dgCountryZone.CurrentCell.ColumnIndex].Name.Equals("Destination Code"))
{
TextBox txt = e.Control as TextBox;
txt.Multiline = false;
txt.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
txt.AutoCompleteSource = AutoCompleteSource.CustomSource;
txt.AutoCompleteCustomSource = colCountryListCodeCheck;
}
}
4. in the time of validation if I am using cells current position its not work
exe: say present cell position is cell(4,5) now user press tab if validate pass then I want to set focus on cell(4,9) or else in cell(4,5) but it moves on cell(4,10) or cell(4,6)
<pre>private void dgCountryZone_CellEndEdit(object sender, DataGridViewCellEventArgs e)
{
Int32 RowCounter;
Int32 DuplicateCounter;
IDataReader idrCountryName;
DuplicateCounter = 0;
if (dgCountryZone.Columns[e.ColumnIndex].Name == "Destination Code")
{
if (Convert.ToString(dgCountryZone.Rows[e.RowIndex].Cells[e.ColumnIndex].Value) != "")
{
for (RowCounter = 0; RowCounter <= dgCountryZone.Rows.Count - 1; RowCounter++)
{
if (Convert.ToString(dgCountryZone.Rows[RowCounter].Cells[e.ColumnIndex].Value) == Convert.ToString(dgCountryZone.Rows[e.RowIndex].Cells[e.ColumnIndex].Value))
{
DuplicateCounter++;
}
}
if (DuplicateCounter > 1)
{
dgCountryZone.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = "";
MessageBox.Show(MessageResource.DuplicateRecord, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
dgCountryZone.CurrentCell = dgCountryZone[e.ColumnIndex, e.RowIndex];
return;
}
else
{
DataAccessLayer daobj = new DataAccessLayer();
UserDataType.CountryParam CParam = new UserDataType.CountryParam();
CParam.szCountryCode = Convert.ToString(dgCountryZone.Rows[e.RowIndex].Cells[e.ColumnIndex].Value);
dgCountryZone.Rows[e.RowIndex].Cells[e.ColumnIndex + 1].Value = "";
idrCountryName = daobj.GetHelpCountryName(CParam);
while (idrCountryName.Read())
dgCountryZone.Rows[e.RowIndex].Cells[e.ColumnIndex + 1].Value = idrCountryName.GetString(0);
if (Convert.ToString(dgCountryZone.Rows[e.RowIndex].Cells[e.ColumnIndex + 1].Value) != "")
{
dgCountryZone.CurrentCell = dgCountryZone[e.ColumnIndex + 1, e.RowIndex];
return;
}
else
{
MessageBox.Show(MessageResource.CodeNotFound, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
dgCountryZone.CurrentCell = dgCountryZone[e.ColumnIndex, e.RowIndex];
return;
}
}
}
else
{
MessageBox.Show(MessageResource.BlankField, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
dgCountryZone.CurrentCell = dgCountryZone[e.ColumnIndex, e.RowIndex];
return;
}
}
if (dgCountryZone.Columns[e.ColumnIndex].Name == "Per CWB/KG")
{
if (Convert.ToString(dgCountryZone.Rows[e.RowIndex].Cells[e.ColumnIndex].Value) != "")
{
if (Convert.ToString(dgCountryZone.Rows[e.RowIndex].Cells[e.ColumnIndex].Value).ToUpper() != "K" && Convert.ToString(dgCountryZone.Rows[e.RowIndex].Cells[e.ColumnIndex].Value).ToUpper() != "W")
{
MessageBox.Show("Please select [W for per CWB] and [K for KG]", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
dgCountryZone.CurrentCell = dgCountryZone[e.ColumnIndex, e.RowIndex];
return;
}
}
else
{
MessageBox.Show(MessageResource.BlankField, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
dgCountryZone.CurrentCell = dgCountryZone[e.ColumnIndex, e.RowIndex];
return;
}
}
}
Please suggest if I am wrong or any code help if possible
Regards
Prakash
Prakash
|
|
|
|
|
Hi,
I'd created a Custom Control using MaskedTextBox and DateTimePicker. I'd written all the required validations and it is working fine. I'd even created a CustomEventHandler by using Delegate. The Problem is when I drag this control on to a form I could not find the CustomEventHandler to raise. Here is my Code. Can anyone suggest the solution. Thanks in Advance
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
namespace DateControl
{
public partial class UserDateControl : UserControl
{
private bool IsTrue;
private bool Err;
private string MskText;
public delegate void DateControlEventHandler();
[Category("Action"),Description("Fires when the Text Changed event Occurs!")]
public event DateControlEventHandler TextChanged;
public UserDateControl()
{
InitializeComponent();
}
protected virtual void OnTextChanged()
{
if (TextChanged != null)
{
TextChanged();
}
}
private void DTPicker_ValueChanged(object sender, EventArgs e)
{
string DTP;
if (DTPicker.Value.Day < 10)
DTP = "0" + DTPicker.Value.Day + "-";
else
DTP = DTPicker.Value.Day + "-";
if (DTPicker.Value.Month < 10)
DTP += "0" + DTPicker.Value.Month + "-";
else
DTP += DTPicker.Value.Month + "-";
DTP += DTPicker.Value.Year;
MskDateControl.Text = DTP;
}
[Category("DateControl Configuration"),Description("Whether the Control should accept more than Today's date?"),DefaultValue(false)]
public bool AcceptMoreThanToday
{
get { return IsTrue; }
set
{
IsTrue = value;
}
}
public string DateValue
{
get { return MskText; }
set
{
MskText = MskDateControl.Text;
}
}
private void MskDateControl_Validating(object sender, CancelEventArgs e)
{
if (MskDateControl.MaskFull == false)
{
errorProvider1.SetError(MskDateControl, "Please Check the Date!");
}
}
private void MskDateControl_TextChanged(object sender, EventArgs e)
{
if (MskDateControl.MaskFull == true)
{
Char[] ChrSep = new Char[] { '-' };
String[] SplitDate;
SplitDate = MskDateControl.Text.Split(ChrSep, 3);
int y = int.Parse(SplitDate.GetValue(2).ToString());
int d = int.Parse(SplitDate.GetValue(0).ToString());
int m = int.Parse(SplitDate.GetValue(1).ToString());
Err = false;
if (m > 12 || m <= 0)
{
Err = true;
errorProvider1.SetError(MskDateControl, "Please Check the Month!");
}
else if (y < 1900)
{
Err = true;
errorProvider1.SetError(MskDateControl, "Please Check the Year!");
}
else if (DateTime.DaysInMonth(y, m) < d)
{
Err = true;
errorProvider1.SetError(MskDateControl, "Please Check the Days!");
}
else if (d > 31 || d <= 0)
{
Err = true;
errorProvider1.SetError(MskDateControl, "Please Check the Days!");
}
else
{
Err = false;
errorProvider1.SetError(MskDateControl, "");
if (TextChanged != null)
{
OnTextChanged();
}
}
if (IsTrue == false && Err==false)
{
DateTime CnvDate = new DateTime(y, m, d);
DateTime SDate = DateTime.Today;
if (CnvDate > SDate)
{
errorProvider1.SetError(MskDateControl, "Date should not be more than Today's Date");
}
}
}
}
private void MskDateControl_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == ' ') e.KeyChar = (char)0;
}
private void MskDateControl_Validated(object sender, EventArgs e)
{
if (Err == false && MskDateControl.MaskFull == true)
{
Char[] ChrSep = new Char[] { '-' };
String[] SplitDate;
SplitDate = MskDateControl.Text.Split(ChrSep, 3);
int y = int.Parse(SplitDate.GetValue(2).ToString());
int d = int.Parse(SplitDate.GetValue(0).ToString());
int m = int.Parse(SplitDate.GetValue(1).ToString());
DateTime EDate = new DateTime(y, m, d);
DTPicker.Value = EDate;
DateValue = MskDateControl.Text;
}
}
}
}
Sreedhar Kadiyala
|
|
|
|
|
It appears that MS has done some fancy hiding on the original TextChanged event for a UserControl.
Firstly, you should mark the event as new so it replaces the inherited implementation then add the following two attributes to it:
[EditorBrowsable(EditorBrowsableState.Always),
Browsable(true)]
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Thank you very much. It worked.
Sreedhar Kadiyala
|
|
|
|
|
i need to write the codeing for QR barcode decoder. i found few sample codings but thats quite complecated....is there any easy way than this? simple way to decode a QR barcode.
Open Source QRCode Library[^]
|
|
|
|
|
S K Y wrote: need to write the codeing for QR barcode decoder. i found few sample codings but thats quite complecated....is there any easy way than this? simple way to decode a QR barcode.
Open Source QRCode Library[^]
...simpler than this? You are probably a bit lazy.
Regards: Didi Kunz
|
|
|
|
|
I have a web application and a console application. I used datetime in both the application. However I need to set the culture of the datetime by the culture of that local. I have configured the application in Itely server, it'w works fine there, however when I configured in India it shows the datetime error.
Pankaj
|
|
|
|
|
And the error looks like? Do you get an error message?
|
|
|
|
|
How can we help if you don't tell us what the error is? Posting the relevant code sample also helps.
Cheers,
Vikram. Recent activities:
TV series: Friends, season 8
Books: Freakonomics, by Steven Levitt and Stephen J Dubner. Carpe Diem.
|
|
|
|
|
I want retrieve tagelements of a html details using c#.
In the html page, if I get
<Label class="splAlink" onMouseOver="hover2(this)" onMouseOut="visited2(this)" onClick="openFile('/20095/PC_COLLECTIONRECEIPT_205092.pdf')" >PC_COLLECTIONRECEIPT_205092</Label>
mshtml.HTMLLabelElement labelElem = (mshtml.HTMLLabelElement)htmlElement; // where htmlElement.outerHTML gives above text
labelElem.onclick gives a object value.
From this object variable how can i get the string "openFile('/20095/PC_COLLECTIONRECEIPT_205092.pdf')"
|
|
|
|
|
Well, did you try to use ToString()? Try to debug your app, set a breakpoint where you access labelElem.onclick and see what type the object is.
Regards
Sebastian
|
|
|
|
|
can any one tell me the tag? i'm a new learner...Please give me code sample..
|
|
|
|
|
The Tag property is of type Object, so you can put anything in there that you like, you'll just need to cast it to the correct type when you want to retrieve it.
For example, If you were making a view of People, you may just be displaying the Surname in each node but you could put the entire Person object in the Tag, so when the node is selected, you can cast the selected node's Tag to Person and retrieve the whole object back again.
BTW, nearly every control has a Tag property, not just a Node.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
I'm really happy and thank you....
Now i know it clearly..
|
|
|
|
|
This is bizarre!
I've got an app in C# that uses DirectSound. I set up the SecondaryBuffer in the normal way, using a WaveFormat struct. It runs fine on my machine and on other machines that have downloaded and installed the latest version of DirectX (DirectX 9.0c (4.09.0000.0904)).
However, on machines that show the exact same DirectX version number, when I run the program, if there is so much as a declaration that there is the slightest chance that I might possibly be considering using a WaveFormat structure, I get a file not found dialog box which tells me there was a "system.io.filenotfoundexception". Nothing in the detailed error report tells me what file was not found.
If I download and install the latest DirectX install, everything is fine. If I UNINSTALL DirectX from the machine, the program STILL WORKS!!! I've been comparing installed DLLs, looking for something that might account for the problem, but so far no luck.
I'm gonna get some pushback from my client if I tell him that all of his customers have to download and install the latest DirectX even if they already think they have it installed. Heck, I'd be pretty annoyed if somebody told me that! But, so far, that's the only solution I've found. I hope somebody else has run into this, or has an idea about tracking down the missing file.
In case it's not clear, all I have to do is have the following line in my code, and the program will not run on a computer that has not had DX re-downloaded and installed:
WaveFormat wFormat;
That's all it takes. And, as I'm sure many of you know, the WaveFormat structure has been around since before the last ice age, it's not something new.
|
|
|
|
|
What does the code look like that is building the path to the sound file?? Please don't tell me your' using CurrentDirectory or are just depending on a filename alone. You should be building a fully qualified path to the file using a known starting point.
|
|
|
|
|
Dave, here's exactly what it takes to get the error:
WaveFormat wFormat;
Nothing else. Nothing. Nada. Just that. Not even:
wFormat = new WaveFormat;
much less setting any of the elements of the structure. I added that line to another program that does nothing with sound, and that runs on every computer. Without the line, all is fine. With the line?
Ooooops.
Like I said, this is bizarre.
|
|
|
|
|
I was typing in a hurry before- to clarify, it doesn't matter if WaveFormat is public, private, or local to a function. Just saying I'm going to use that data structure causes the problem, but only on machines that have not installed the latest version of DX.
For perspective, I've been writing or supervising the writing of audio drivers and applications for 25 years. That doesn't mean I'm not doing something incredibly stupid- in fact I'd much rather find out it was a brain fart on my part as opposed to paging through lists of all the system DLLs on my machine and comparing them to a machine where the program fails. I just hope it's not something in the registry!
I tried a little drum machine program called winrhythm which, if I recall correctly, I found on an MSDN site. If I compile it on my machine and try to run it on one of the problem machines I get the same error. I also tried adding everthing including the kitchen sink to the references. It didn't make any difference.
I'm relatively new to C#, my first thought was that somehow I had not correctly set up the wave files (which are resources, not external files). I wish it had been that simple.
I did install the full DX SDK with redistributables on this computer, and as far as I know that has not been installed on the other computers. It seems likely that some file is installed in that process that is not installed on an end-user computer. If anybody has any suggestions as to which DLL information about the waveformat data structure is found I would greatly appreciate it!
|
|
|
|
|
Possibly (probably) a long shot, but are you installing a release or debug version when you get the problem?
I've run into similar errors, as the DX redist installs only the release DLLs. That usually generates a "Doh!" moment for me
The actual DLL it's looking for will depend on whether you're using managed or unmanaged DirectX, and whether it's an X86 or X64 build, but have a look for "dsound.dll" in you Windows/System32 or SysWOW64 directories.
There are three kinds of people in the world - those who can count and those who can't...
|
|
|
|
|
Are you talking about release/debug version of DX or of the program I'm working on? In theory it's a release version of the program, although I have had questions about that since it's the same size as the debug version and is created in the /bin/debug directory. I moved the dsound.dll from my machine to one of the problem machines, with no joy.
How do I tell whether I'm using managed or unmanaged DX? I'm compiling for "any CPU", which I assume means X86.
I think I just had my "Doh!" moment- I should be able to define my own structure and use it. Hopefully C# won't be too outraged. Having cut my teeth on machine code it can be annoying to have a compiler insist it knows what I really mean, especially when it's wrong! But C# is pointer-based, so there is no inherent reason it can't take a pointer to a struct that is exactly what it wants instead of a system reference that doesn't work on some computers.
|
|
|
|
|
So much for the easy way. C#, the all-wise and all-knowing, must protect me from using my own identical structure...
I probably shouldn't go on a rant about C# on a forum full of C# users, but in my opinion it's better to learn how to write safe code than expect a compiler to take care of managing everything.
|
|
|
|
|
tjeffries wrote: Are you talking about release/debug version of DX or of the program I'm working on?
I meant your program. You'll be able to run a debug build on any machines that have the full SDK installed, but for machines with just the redistributable, you'll only be able to run release builds.
tjeffries wrote: In theory it's a release version of the program, although I have had questions about that since it's the same size as the debug version and is created in the /bin/debug directory.
That sounds suspicious. It should definitely be smaller, and be in the "Release" directory. I'd have a good look at your build options to check.
tjeffries wrote: How do I tell whether I'm using managed or unmanaged DX?
The managed interfaces are a bit different, although if you're accesing it directly from C# with something like "using Microsoft.DirectX.DirectSound" then it may be the managed version. The DLLs are different, and in a different place (which I can't remember t the moment).
tjeffries wrote: I'm compiling for "any CPU", which I assume means X86.
You might need to also check the build target in the project properties build tab. As well as the overall configuration, there's a specific target option hidden there (I sometimes forget it as well, and get bitten by it). Make sure this is set to X86, and not "Any CPU" or X64. That might be what you need to change...
tjeffries wrote: I should be able to define my own structure and use it.
It's possible, although the compiler might get picky about types and complain about it. If nothing else works, then it's worth a try...
There are three kinds of people in the world - those who can count and those who can't...
|
|
|
|
|
Right now the release/debug issue seems the most likely. I found the X86 tab, thanks, but despite the fact that the Build tab of the project properties windows says Release and the output directory is /bin/release, the program is the same size it is when built for debugging, and the files are put in /bin/debug. I thought the former might be some strange C# artifact, but maybe not.
Dumb question time- if I set the Build tab up correctly, click on "Clean Solution" (as far as I can tell, that just removes the exe, but maybe it does something else) and then click on "Build Solution" or "Rebuild Solution", it should build either a debug or release version depending on the settings, right? Is there something hidden away in a corner (or even in front of my eyes, so obvious that only a fool could miss it) that I need to do in order to get this to build the correct version?
Yes, the compiler got very upset at me for trying to do something so UNSAFE!!! as create my own structure exactly like the one Windows uses. Shame on me for even thinking of such a thing.
|
|
|
|
|
OK, color me blind and not-too-bright. Just below the top menu bar there is the "standard" toolbar that specifies debug/release and processor. Changing the settings there has affected the file size and the directory it is written to. I'll see if it makes a difference in whether it works on a machine that does not have the SDK installed.
|
|
|
|
|