1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Retrieve Int Value from dataGridView

Discussion in 'C#' started by Ange1ofD4rkness, Aug 28, 2010.

  1. Ange1ofD4rkness

    Ange1ofD4rkness New Member

    Aug 28, 2010
    Likes Received:
    Trophy Points:
    Okay so I feel stupid for asking this and I feel like i am overlooking something, but how do retrieve the value of a datagridview cell as an int. I have used this code to change the column to type int

    dataGridView1.Columns[0].CellTemplate.ValueType = typeof(int);
    I haven't really had a chance to test this line of code above, but I beleive this will work (this data grid view contains 3 colums for intgredients the first is the count of how much the item is needed, the second column is the type of measurement suc as lbs or oz, and the third column is the name of the ingredient)

    So how do I read that first columns value as an int? (I am storing it in an object array as a type int). I mean I could probably do some annoying and wasteful code to convert it from a string to and int but I feel like their is something better to do it.

    I mean I know this is how to read a string

    store.inMeasure(dataGridView1[1, i].ToString());
    But how do I read as an int

    (oh also if anyone knows a way or a web link to do suggestive typing. By this I mean like excel does where if you start typing a simialr word it gives you an option to have it filled in well for me I want to do it on the second and third column above (think about making a menu with drag and drop and a shopping list is compiled by adding up simialer names))

Share This Page