Question Datagridview with masked edit box

madgoose

Member
Joined
Aug 20, 2009
Messages
5
Programming Experience
10+
I am completely unable to make work the datagridview using maskededit.

VB.NET:
dgv1.Columns("BudgetDate").DefaultCellStyle.Format = "$#.00"

In above example I am getting error - "Object reference not set to an instance of an object."

Suggested by error to use new keyword.

I've tried several alternatives to the mask and do not feel the mask string is the issue.
edit:
I've found the issue. must use column Number, not column Name.

VB.NET:
dgv1.Columns("Column3").DefaultCellStyle.Format = "##/##/####"
Howver, the mask does not display. ideas?
 
Last edited:
Thanks JohnH. I have the masked edit solution provided by vb-tips.com. i was hoping a less wordy solution existed. I have about 10 colums to format and that solution is kind of long on coding.

Thanks for confirming that I wasn't a complete idiot. I think
 
I have about 10 colums to format and that solution is kind of long on coding.
What, about 4-5 lines per column, possibly done once in a loop? :)
 
That makes sense, but I have 8 columns, 6 need formating. 3 each as currency, 3 as date. Should each column be created programatically? Or an I apply the mask to the column if its created within the designer?

I can easily enough apply the proper mask based on the loop count, but this doesn't seem to be the proper method. I suppose I am confused about the proper method of creating the columns in this case.
 
The masked column you can add, or replace, programmatically - or use designer. When I copied those classes the column appeared in Add Column dialog.
 
Back
Top