Click here to Skip to main content
15,921,467 members
Home / Discussions / C#
   

C#

 
QuestionView state Pin
kalyan_241616-Feb-07 21:46
kalyan_241616-Feb-07 21:46 
AnswerRe: View state Pin
Michael Sync16-Feb-07 23:03
Michael Sync16-Feb-07 23:03 
QuestionRequest Pin
md_refay16-Feb-07 20:51
md_refay16-Feb-07 20:51 
Questionconfused phrases Pin
md_refay16-Feb-07 20:44
md_refay16-Feb-07 20:44 
AnswerRe: confused phrases Pin
Stefan Troschuetz16-Feb-07 20:58
Stefan Troschuetz16-Feb-07 20:58 
Questionconfused phrases Pin
md_refay16-Feb-07 20:42
md_refay16-Feb-07 20:42 
QuestionValidating Data in a datagridView Pin
Rocky#16-Feb-07 20:11
Rocky#16-Feb-07 20:11 
AnswerRe: Validating Data in a datagridView Pin
iylbq24716-Feb-07 22:11
iylbq24716-Feb-07 22:11 
Hey Rocky,

In the bit of testing I did the KeyPress event only fires when the cell is not being edited and the key was a Tab key. I've included some code that will do the trick. It's probably not the most cycle efficient but it works.

<br />
private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)<br />
        {<br />
            if ( ((DataGridView)sender).CurrentCell == null ) return;<br />
            if (((DataGridView)sender).CurrentCell.Value == null) return;<br />
<br />
            string str = ((DataGridView)sender).CurrentCell.Value.ToString();<br />
            if (this.ContainsOnly(str, "1234567890"))<br />
            {<br />
                MessageBox.Show("true");<br />
            }<br />
            else<br />
            {<br />
                MessageBox.Show("False");<br />
                ((DataGridView)sender).CurrentCell.Value = null;<br />
            }<br />
        }<br />
<br />
        private bool ContainsOnly(string str, string anyOf)<br />
        {<br />
            bool result = true;<br />
            Char[] str2 = str.ToCharArray();<br />
<br />
            for (int i = 0; i < str2.Length; i++)<br />
            {<br />
                result = result && (anyOf.IndexOfAny(str[i].ToString().ToCharArray()) >= 0);<br />
                if (!result) break;<br />
            }<br />
<br />
            return result;<br />
        }<br />

GeneralRe: Validating Data in a datagridView Pin
Rocky#17-Feb-07 23:28
Rocky#17-Feb-07 23:28 
Questionwriting to a text file that may not exsist Pin
alostdruid16-Feb-07 18:47
alostdruid16-Feb-07 18:47 
AnswerRe: writing to a text file that may not exsist Pin
Stefan Troschuetz16-Feb-07 20:51
Stefan Troschuetz16-Feb-07 20:51 
AnswerRe: writing to a text file that may not exsist Pin
Wayne Phipps17-Feb-07 3:34
Wayne Phipps17-Feb-07 3:34 
QuestionCube and Data mining on Forms, how? Pin
TrooperIronMan16-Feb-07 14:49
TrooperIronMan16-Feb-07 14:49 
QuestionDataGridView - Bound to XMLDataDoc [modified] Pin
CopperMedal16-Feb-07 14:20
CopperMedal16-Feb-07 14:20 
AnswerRe: DataGridView - Bound to XMLDataDoc Pin
CopperMedal17-Feb-07 8:07
CopperMedal17-Feb-07 8:07 
Questionfile transfer Pin
giltendezm16-Feb-07 14:16
giltendezm16-Feb-07 14:16 
AnswerRe: file transfer Pin
Niiiissssshhhhhuuuuu16-Feb-07 16:47
Niiiissssshhhhhuuuuu16-Feb-07 16:47 
GeneralRe: file transfer Pin
giltendezm16-Feb-07 18:01
giltendezm16-Feb-07 18:01 
GeneralRe: file transfer Pin
Niiiissssshhhhhuuuuu16-Feb-07 19:18
Niiiissssshhhhhuuuuu16-Feb-07 19:18 
GeneralRe: file transfer Pin
Niiiissssshhhhhuuuuu16-Feb-07 19:27
Niiiissssshhhhhuuuuu16-Feb-07 19:27 
GeneralRe: file transfer Pin
giltendezm16-Feb-07 19:49
giltendezm16-Feb-07 19:49 
GeneralRe: file transfer Pin
Niiiissssshhhhhuuuuu16-Feb-07 19:56
Niiiissssshhhhhuuuuu16-Feb-07 19:56 
QuestionExcel ListObject to XmlDocument C# [modified] Pin
Raghutoo16-Feb-07 13:13
Raghutoo16-Feb-07 13:13 
QuestionDateTime Pin
Expert Coming16-Feb-07 12:37
Expert Coming16-Feb-07 12:37 
AnswerRe: DateTime Pin
Guffa16-Feb-07 13:58
Guffa16-Feb-07 13:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.