private void Initilise_grd_img(object sender, EventArgs e) { // set up grd_image when image tab is selected for the first time after form loads dttable_img = vehicle_model_image_ds.Select_vehicle_model_image(Model_id); grd_img.DataSource = null; grd_img.DataSource = dttable_img; if (!Program.System_user.IsDeveloper) { Class_datagridview.Hide_unnecessary_columns(grd_img, new string[] { "image" }); } ((DataGridViewImageColumn)grd_img.Columns["image"]).ImageLayout = DataGridViewImageCellLayout.Zoom; if (grd_img.Rows.Count == 0) { return; } foreach (DataGridViewRow grd_row in grd_img.Rows) { grd_row.Height = Program.GRD_IMAGE_ROW_HEIGHT; } grd_img.ClearSelection(); grd_img.CurrentCell = null; // detach event handler after initilising images. this.tabControl1.SelectedIndexChanged -= new System.EventHandler(this.Initilise_grd_img); }
private void Form_datagridview_select_Shown(object sender, EventArgs e) { Class_datagridview.Setup_search_textbox(txt_search.TextBox, grd_main); switch (_form_type) { case "PERSON_ORGANISATION": lbl_type.Visible = true; cmb_type.Visible = true; Setup_person_organisation_form(); break; } grd_main.AutoResizeColumns(); if (_cols_to_display != null && _cols_to_display.Count() > 0) { Class_datagridview.Hide_unnecessary_columns(grd_main, _cols_to_display); } if (_value_col_name != "") { Class_datagridview.Select_row_by_value(grd_main, _value_col_name, _preselect_value); } }
private void Form_edit_insurance_comprehensive_Shown(object sender, EventArgs e) { if (!Program.System_user.Has_permission(Class_enum.User_permission.INSURANCE_COMPREHENSIVE_ADD_EDIT)) { MessageBox.Show("ACCESS DENIED", "ACCESS DENIED", MessageBoxButtons.OK, MessageBoxIcon.Error); this.DialogResult = DialogResult.Cancel; this.Close(); } if (InsuranceComprehensive != 0) { using (Insurance_comprehensive_ds.sp_select_insurance_comprehensiveDataTable dttable = Insurance_comprehensive_ds.Select_insurance_comprehensive(InsuranceComprehensive)) { if (dttable.Any()) { txt_title.Text = dttable[0].title; } } } using (Insurance_comprehensive_rate_ds.sp_select_insurance_comprehensive_rateDataTable dttable = Insurance_comprehensive_rate_ds.Select_insurance_comprehensive_rate(InsuranceComprehensive, -1)) { dttable.insurance_comprehensiveColumn.ReadOnly = true; dttable.modified_byColumn.ReadOnly = true; // not showing column but column needs value dttable.insurance_comprehensiveColumn.DefaultValue = InsuranceComprehensive; dttable.cc_minColumn.DefaultValue = 0; dttable.cc_maxColumn.DefaultValue = 0; dttable.valueColumn.DefaultValue = 0; // not showing column but column needs value dttable.modified_byColumn.DefaultValue = Program.System_user.Name; // columns must have value! dttable.cc_minColumn.AllowDBNull = false; dttable.cc_maxColumn.AllowDBNull = false; dttable.valueColumn.AllowDBNull = false; grd_ins.DataSource = dttable; if (!Program.System_user.IsDeveloper) { Class_datagridview.Hide_unnecessary_columns(grd_ins, new string[] { "cc_min", "cc_max", "value" }); } Class_datagridview.Set_column_to_money_column(grd_ins, "value"); grd_ins.Columns["modified_by"].ReadOnly = true; grd_ins.Columns["modified_by"].DefaultCellStyle.BackColor = Color.LightGray; } }
private void Setup_grd_model(int int_vmodel = 0) { if (tv_vehicle.SelectedNode == null) { return; } int int_country = int.Parse(Class_treeview.Get_parent_node_by_level(tv_vehicle.SelectedNode, 0).Name); int int_vbrand = -1; int int_vgroup = -1; if (tv_vehicle.SelectedNode.Level > 0) { int_vbrand = int.Parse(Class_treeview.Get_parent_node_by_level(tv_vehicle.SelectedNode, 1).Name); } if (tv_vehicle.SelectedNode.Level > 1) { int_vgroup = int.Parse(Class_treeview.Get_parent_node_by_level(tv_vehicle.SelectedNode, 2).Name); } grd_model.DataSource = null; grd_model.DataSource = Vehicle_model_ds.Select_vehicle_model(int_country, int_vbrand, int_vgroup, -1); if (!Program.System_user.IsDeveloper) { Class_datagridview.Hide_unnecessary_columns(grd_model, new string[] { "vehicle_model_name", "year_make", "engine_capacity", "no_of_door", "seat_capacity", "fuel_type_name", "transmission_name", "vehicle_group_name", "vehicle_brand_name", "country_name" }); } grd_model.AutoResizeColumns(); if (int_vmodel != 0) { foreach (DataGridViewRow grd_row in grd_model.Rows) { if (int.Parse(grd_row.Cells["vehicle_model"].Value.ToString()) == int_vmodel) { grd_model.ClearSelection(); grd_row.Cells["vehicle_model_name"].Selected = true; grd_model.CurrentCell = grd_row.Cells["vehicle_model_name"]; break; } } } }
private void Listbox_ins_SelectedIndexChanged(object sender, EventArgs e) { if (listbox_ins.SelectedIndex >= 0) { grd_ins.DataSource = null; grd_ins.DataSource = Insurance_comprehensive_rate_ds. Select_insurance_comprehensive_rate((int)listbox_ins.SelectedValue, -1); Class_datagridview.Set_column_to_money_column(grd_ins, new string[] { "value" }); grd_ins.AutoResizeColumns(); if (!Program.System_user.IsDeveloper) { Class_datagridview.Hide_unnecessary_columns(grd_ins, new string[] { "cc_min", "cc_max", "value", "modified_by" }); } } }